简体   繁体   中英

javascript form onload doesn't work in Safari

My goal is to open a new window when the user clicks on the link and then reload the main page to go back to the previous content. The first code snippet below works in IE and FireFox but doesn't pop a new window in Safari. The second code snippet works in all 3 browsers but in Safari doesn't perform the history.go(-1); to go back to the previous page on a main window.

Also, in a second snippet, if I put "return true;" after "history.go(-1);" history.go(-1); does work but the new window doesn't pop up (target=""_blank"").

Any suggestions?

Thanks, Ryan

<html> <body> <form id="sso" method="POST" action="/apps/Integration/SsoUtil/SiteTransfer/SsoSignonSaml2Url.aspx" target="_blank" >
    <input type="hidden" size=150 name="SsoEncryptedData" value="<%=cd.ToSsoEncryptedB64()%>" /> </form> </body>

  <script>
    sso.submit();
    history.back();   </script> </html>


------------------WORKS IN SAFARI BUT DOESN"T RELOAD THE PARENT PAGE-----------------------
<%
Response.Write("<html>")
            Response.Write("<body onload=""document.getElementById('sso').submit();return true; history.go(-1);"">")

            Response.Write("<form id=""sso"" method=""POST"" action=""/Apps/Integration/SsoUtil/SiteTransfer/SsoSignonSaml2Url.aspx"" target=""_blank"">")

            Response.Write("</form><br/>")
            Response.Write("</body>")
            Response.Write("</html>")
            Response.End()
%>
-------------------------------------------------------------------------------------------

Try

<script>
sso.submit();
setTimeout(function() { history.back();},1000)   
</script>

then try returning <script>opener.history.back()</script> from your server when you submit Lastly give your form a submit button and try clicking it instead of submitting the form document.getElementById('subbut').click()

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM