windows.location.href not working on Firefox3

前端 未结 17 1128
囚心锁ツ
囚心锁ツ 2020-11-30 07:31

We have a JavaScript function named \"move\" which does just \"windows.location.href = any given anchor\".
This function works on IE, Opera and Safari, but so

17条回答
  •  隐瞒了意图╮
    2020-11-30 08:14

    If you are trying to call this javascript code after an event that is followed by a callback then you must add another line to your function:

    function JSNavSomewhere()
    {
        window.location.href = myUrl;
        return false;
    }
    

    in your markup for the page, the control that calls this function on click must return this function's value

    
    

    The false return value will cancel the callback and the redirection will now work. Why this works in IE? Well I guess they were thinking differently on the issue when they prioritized the redirection over the callback.

    Hope this helps!

提交回复
热议问题