admin管理员组文章数量:1406924
I want to run a pushState
and it works fine but when I load the page through an iframe element it refused to work. This is how my code looks like
$('a[href]').click(function){
newHref = $(this).attr('href');
history.pushState('', '', newHref);
})
But it's not working, Please anyone with an idea of how to achieve this?
I want to run a pushState
and it works fine but when I load the page through an iframe element it refused to work. This is how my code looks like
$('a[href]').click(function){
newHref = $(this).attr('href');
history.pushState('', '', newHref);
})
But it's not working, Please anyone with an idea of how to achieve this?
Share Improve this question asked Nov 8, 2016 at 15:11 doggie brezydoggie brezy 2973 silver badges17 bronze badges2 Answers
Reset to default 6Using history.pushState()
changes the url of the iframe source page. To change the main url in the address bar you have to address it to the parent so use this
window.parent.history.pushState();
You should just need to keep the function called wrapped in the click event parenthesis...
$('a[href]').click(function(e){
e.preventDefault();
newHref = $(this).attr('href');
history.pushState('', '', newHref);
});
本文标签: jqueryjavascript historypushState not working for iframeStack Overflow
版权声明:本文标题:jquery - javascript history.pushState not working for iframe - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744972875a2635339.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论