My script works fine under chrome, but not under Firefox. Firefox simply shows me a white screen. The redirection must happen with POST.
<!DOCTYPE html>
<html>
<script type='text/javascript'>
//<![CDATA[
var redirect = function(url, method) {
var form = document.createElement('form');
form.method = method;
form.action = url;
form.submit();
};
redirect('/mywebservice/mainpage', 'post');
//]]>
</script>
</html>
You can't submit a form that isn't part of the page.
Add document.body.appendChild(form); before you try to submit it.
You can't do that before the body exists though. Add a <body> start tag before the script. In future, also run your code through a validator.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With