Firefox pop-under

前端 未结 2 431
刺人心
刺人心 2021-01-16 11:49

I have a simple page:



  

        
2条回答
  •  北恋
    北恋 (楼主)
    2021-01-16 12:29

    so i've actually hacked away and got something somewhat working in Firefox. i have to say that this was very fast and very ugly, but i don't think i've ever given a good (or even decent) answer on here so may as well try to start. :P also, i should state that i'm triggering the pop under on submission of a form but you could trigger it on page load if you wanted. i have the booleans in there to ensure it doesn't pop under more than once. if anyone wants to clean up my code and show a more straight forward solution (i.e. without multiple booleans/functions and the setTimeout) i'm sure we'd all be grateful.

    var submitted = false;
    var redir = false;
    function do_window_location() {
        if(submitted == false) {
            $('form').submit();
            submitted = true;
        }
        window.location = 'http://www.google.com';
    }
    function call_window_location() {
        if(redir == false) {
            setTimeout('do_window_location()', 100);
            redir = true;
        }
    }
    $('document').ready(function() {
        $('form').submit(function() {
            if(submitted == false) {
                call_window_location();
                $(this).submit();
                submitted = true;
            }
        });
        return true;
    });
    

    hope this helps someone in some fashion.

提交回复
热议问题