如何在javaScript中从iframe读取动态queryString? [英] How to read dynamic queryString from iframe in javaScript?
本文介绍了如何在javaScript中从iframe读取动态queryString?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
嗨
我的页面中有一个iframe标签
当iframe年龄加载时
。它生成一个查询字符串
我想用queryStrings读取页面网址
但它只是显示我的iframe src!
function getiframeURL()
{
alert( document .getElementById(' myframe'跨度>)SCR)。
}
解决方案
w3schools :注意:由于安全原因,只有当两个文档位于同一个域中时,才能从另一个文档访问文档的内容。
如果包含页面和iframe / frame目标属于在同一个域中你可以使用这一行:
alert( document .getElementById( myframe')。documentWindow。 location .href);
Hi
I have an iframe tag in my page
when iframe age load . it generate a query String
I want to read the page url with queryStrings
but it just show my iframe src !
function getiframeURL()
{
alert(document.getElementById('myframe').scr);
}
解决方案
w3schools:Note: Because of security reasons, the contents of a document can be accessed from another document only if the two documents are located in the same domain.
If the containing page and the iframe/frame target belong to the same domain you can use this line:
alert(document.getElementById('myframe').documentWindow.location.href);
这篇关于如何在javaScript中从iframe读取动态queryString?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文