开发者

javascript scroll to parent over http and https using javascript

I have a secure (https) 开发者_如何学编程iFrame within a non-secure (http) page. When the user clicks on link in the iFrame, a new iFrame page loads.

However, because the first iFrame page is quite long, when it moves to the next page the parent page is still scrolled to the bottom. I use the code-

parent.scrollTo(0,0);

and it works, but not when the iFrame page is running over https.

I get the error (Firefox)- Permission denied for https://www.example.com to get property Window.scrollTo from http://www.example.com

I think this is to stop xss attacks. I'm sure I've done a workaround to this before in javascript? Or is there a way I can set "allowed domains" on the parent page?


I fixed it by putting this in the container page-

jQuery(function(){
 jQuery('#iframe').load(function(){
  window.scrollTo(0,0);
 });
});
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜