SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Addict
    Join Date
    Apr 2010
    Posts
    390
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    javascript safari brwoser issue

    Hi i have this script which has a submit button what the javascript does is if user doesnt select an option from the drop down menu an alert pops up saying (select tv option)

    The problem is it works fine all al browsers except on safari if the user select one option and (click here to view) the new page opens on a new new tab now if you try to select a new option again and click the the submit button (click here to view) it doesnt work on second selection it the issue seems to be only on safari all other browsers work fine please help
    my site is this one http://www.estateagentsonfilm.co.uk/builders.php the drop down is the (select tv agent drop down ) then click here to view if you try select and click twice doesnt work only on safari
    this my javascript
    Code:
    <script type="text/javascript">
    	function checkAgent() {
    		if (document.getElementById('agent_select').value=='none') {
    			alert('Select Web TV');
    			return false;
    		}
    		return true;
    	}
    </script>
    the form that calls the script
    PHP Code:
    form id="agents" action="agents_jump.php" onsubmit="return checkAgent();" method="post"  target="_blank" name="agents" style="margin:0;"

  2. #2
    SitePoint Addict
    Join Date
    Apr 2010
    Posts
    390
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi i thsi is a simple example of my issue if you test this script on safari by selecting the from the drop down twice you'll notice that second time it doesnt work but if you test on a differnt browser it works any help would be much appreciated
    PHP Code:
    <html>
    <
    head>
    <
    script type="text/javascript">
       function 
    checkAgent() {
          if (
    document.getElementById('agent_select').value=='none') {
             
    alert('Select Web TV');
             return 
    false;
          }
          return 
    true;
       }
    </script>
    </head>
    <body>

    <form id="agents" action="agents_jump.php" onsubmit="return checkAgent();" method="post"  target="_blank" name="agents" style="margin:0;">
    <select name="agents" id="agent_select" size="1" style="width:160px; font-size:13px;">>
      <option value="none">Volvo</option>
      <option>Saab</option>
      <option>Mercedes</option>
      <option>Audi</option>
    </select>

    <input class="view_agents" id="tvoption" type="image" src="images/viewagents.gif" alt="TV OPTION" name="tvoption"  border="0"   onclick="jwplayer().stop();">
    </form>   
    </body>
    </html> 

  3. #3
    Programming Since 1978 silver trophybronze trophy felgall's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, NSW, Australia
    Posts
    16,789
    Mentioned
    25 Post(s)
    Tagged
    1 Thread(s)
    document.getElementById('agent_select').value

    should be:

    document.getElementById('agent_select')[document.getElementById('agent_select').selectedIndex].value

    as the select has an array of values attached to it and you need to tell it to pick the selected one. Only some browsers map the selected value to the value attribute of the select.
    Stephen J Chapman

    javascriptexample.net, Book Reviews, follow me on Twitter
    HTML Help, CSS Help, JavaScript Help, PHP/mySQL Help, blog
    <input name="html5" type="text" required pattern="^$">

  4. #4
    SitePoint Addict
    Join Date
    Apr 2010
    Posts
    390
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi thanks for taking the time to help unfortunnaly that made no effect on safari still only pick the script one
    i was told this amongs the lines
    just safari being smart enough to block an attempt of the website to open a new window that has already been opened by the website. Every browser should have that feature IMO
    could that be the reason why?

  5. #5
    SitePoint Addict
    Join Date
    Apr 2010
    Posts
    390
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    hi i have tried by settimg time out reload the page works fine but after that i also wanted to stop the video from playing but the stop function doesnt work
    PHP Code:
        function checkAgent() {
            if (
    document.getElementById('agent_select').value=='none') {
                
    alert('Select Web TV');
                return 
    false;
            }
             
    setTimeout(function(){ location.reload(); jwplayer().stop(); },2000); // page will reload after 2 seconds
            
    return true;
        }
    </script> 


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •