Keeping pages inside an iframe

痞子三分冷 提交于 2019-12-13 06:44:04

问题


I am trying to put a website inside an iframe, but this code on the site keeps changing the window of the page. Is there anyway I can get around this? Or better yet, can I disable javascript in an iframe?

if(top!=self){
  if(top.location)
    top.location=self.location;
  else
    top.location='http://example.com/not_subframe.html';
}

回答1:


Yes it is possible, there are several methods of anti-frame busting including disabling JS in a frame (sandboxing, designMode). All described in Limitations of OWASP:Defending_with_Frame_Breaking_Scripts.

Generally use it only with intranet or restricted access site. If you expose site publicly with such tricks you may expect blacklisting by Google or others.




回答2:


You can only access the content of one frame from within another frame if both frames are from the same domain.

Otherwise this would be an XSS issue which is therefore forbidden by a browser.




回答3:


Nope, can't be done. Not to mention it's usually a bad practice.




回答4:


Web pages cannot disable JavaScript, if they could, it would be mayhem.




回答5:


iFrames have a variety of security features to try to block what you're doing.



来源:https://stackoverflow.com/questions/4728895/keeping-pages-inside-an-iframe

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!