windows.location.href not working on Firefox3

前端 未结 17 991
囚心锁ツ
囚心锁ツ 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:12

    please add full javascript script tag

    <script type="text/javascript" language="javascript"></script>
    0 讨论(0)
  • 2020-11-30 08:13

    Maybe it's just a typo in your post and not in your code, but it's window and not windows

    0 讨论(0)
  • 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

    <asp:button ........ onclick="return JSNavSomewhere();" />
    

    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!

    0 讨论(0)
  • 2020-11-30 08:14

    I am not sure to follow you.
    I just tried: going with FF3 to Lua 5.1 Reference Manual (long and with lot of anchors).
    Pasting javascript:window.location.href="#2.5"; alert(window.location.href); in the address bar, I went to the right anchor and it displayed the right URL. Works also with a full URL, of course.
    Alternative code: javascript:(function () { window.location.href="#2.5"; })();

    Perhaps you forgot the #. Common problem, also with image maps.

    0 讨论(0)
  • 2020-11-30 08:14

    Another option:

    document.location.href ="..."
    
    0 讨论(0)
  • 2020-11-30 08:16
    window.location.hash = "#gallery";
    
    0 讨论(0)
提交回复
热议问题