Firefox重定向部分错误

时间:2016-05-27 13:35:11

标签: html firefox web firebug

我尝试通过以下链接重定向到我的网站价格部分:https://www.paydomestic.com.br/#pricing

<a href="https://www.paydomestic.com.br/#pricing"></a>

Google Chrome正常运行,已经在firefox中无效了。

但这只会通过链接发生,如果您输入网址&#34; https://www.paydomestic.com.br/#pricing&#34;并在浏览器中按Enter键,但不能通过链接!

为什么会这样?

1 个答案:

答案 0 :(得分:0)

<强>解决

<script>
/*location.hash returns the anchor part of an URL as a string, 
with hash (#) symbol included. */
//wait for page elements to load
//execute function only if the anchor exists in the URL address
window.onload = function() {if(location.hash){
    //remove # from the string
    var elId = location.hash.replace('#','');
    //locate the anchored element on the page by its ID property 
    var scrollToEl = document.getElementById(elId);
    //scroll to the anchored element
    scrollToEl.scrollIntoView(true);   
}
 }
</script>