Q:

Firefox redirect with post doesn't work

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>

A:

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.

