A form on my website is not functioning correctly in Safari/Chrome. When a user submits the form, it opens up a new tab, but I want the original page (page with the form on it) to reload. It works in IE, Opera, and Firefox.
The Code:
<form action="/search.php" method="post" onsubmit="location.reload(true)" target="_blank" name="myform">
I tried other javascript functions like:
- window.location.reload();
- document.location.reload();
- window.location.replace('http://www.websiteurl.com');
- window.location.href='http://www.websiteurl.com';
- And other variations of these.
I thought maybe it was the onsubmit="" not working, but when I tried onsubmit="alert('test')" that worked fine in both Safari/Chrome.
Also, on the search.php page that the form posts to, if a user goes directly to the page using the url, and not submitting the form, I have it set that the body tag will load as:
<body onload="window.location.replace("http://www.websiteurl.com")>
which works on all browsers includeing Safari/Chrome.
What is going on here?!?!
Thanks!
setTimeout
hack works: jsfiddle.net/xzanQ. – Plucky