我需要重定向到一个url,当url不允许在框架内

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

本文关键字:url 不允许 框架 一个 重定向      更新时间:2023-09-26

因为我可以重定向到一个页面时,这不能显示在一个iframe,例如谷歌,如果你不加载iframe重定向谷歌直接

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

出于安全原因(跨浏览器功能),您不能使用JQuery访问来自不同域的iframe中的元素。你不能访问iframe中的任何属性。Iframe可能不是最好的选择