homepage Welcome to WebmasterWorld Guest from 54.196.225.45
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member
Home / Forums Index / Code, Content, and Presentation / JavaScript and AJAX
Forum Library, Charter, Moderator: open

JavaScript and AJAX Forum

    
Form submit opens two pages but not in chrome or safari
Can anyone help?
shadowlight




msg:4566100
 7:36 pm on Apr 18, 2013 (gmt 0)

ok, I have some javascript code that enables one html form to open two pages on submit, one in the same window and the other in a new window. This works fine in IE and FF although not in Chrome or Opera.

Can anyone shed any light on this? Here is the code:

echo '<script language="Javascript" type="text/javascript">
function OnButton5()
{
document.getElementById(\'form_name\').action="urlopen1.php"

document.getElementById(\'form_name\').target="_blank";

document.getElementById(\'form_name\').submit();

return true;
}

function OnButton6()
{
document.getElementById(\'form_name\').action="urlopen2.php"

document.getElementById(\'form_name\').target="_self";

document.getElementById(\'form_name\').submit();

return true;
}
</script>';


The actual code as part of the html form which calls these javascript functions is this:

onclick="OnButton5(); OnButton6();"

Can anyone give any advice on how to make this cross browser compatible in order to work in chrome and safari as well as IE and FF.

TIA

 

Jen1




msg:4568795
 2:41 am on Apr 29, 2013 (gmt 0)

That is an interesting issue, I saw the same thing happening to me.
I tested this and it should work for you in multiple browsers.

change your onclick to:
onclick="javascript:OnButton5();"

and add this to OnButton5() function...
setTimeout("OnButton6();",500);

LisaMugal




msg:4570011
 12:04 pm on May 2, 2013 (gmt 0)

s

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / JavaScript and AJAX
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved