简体   繁体   English

当该网址不允许在iframe中时,我需要重定向到该网址?

[英]I need to redirect to a url, when the url not allowed to be inside a iframe?

as I can redirect to a page when this can not be shown in an iframe, for example google, if you do not load the iframe redirect google directly. 因为当您不直接加载iframe重定向google时,如果无法在iframe中显示此页面(例如google),我可以重定向到该页面。

<script type="text/javascript">       
function redirect(iframe)
{
window.location = iframe.src;
}
</script>
<iframe src="http://www.google.com" onerror="redirect(this)"></iframe>

for security reasons (cross-browser functionality), You can't access elements in an iframe from a different domain with JQuery. 出于安全原因(跨浏览器功能),您无法使用JQuery从其他域访问iframe中的元素。 you don't have access to any properties within an iframe.iframe probably isn't the best to rely on. 您无权访问iframe中的任何属性。iframe可能不是最好的依赖。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM