Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/86.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
使用javaScript获取iframe查询字符串_Javascript_Html - Fatal编程技术网

使用javaScript获取iframe查询字符串

使用javaScript获取iframe查询字符串,javascript,html,Javascript,Html,我有一个iframe。当页面加载时,页面将生成查询字符串 我需要访问页面加载后生成的查询字符串 但是有了这段代码,我就可以访问src,而不需要查询字符串 alert(document.getElementById('myframe').src); 尝试: 其中myframe是框架的id请参阅我的父url:localhost/web\u social和我的iframe url:localhost:8585/something在控制台中获取此错误:未捕获类型错误:无法读取未定义的htmlpage

我有一个iframe。当页面加载时,页面将生成查询字符串

我需要访问页面加载后生成的查询字符串

但是有了这段代码,我就可以访问src,而不需要查询字符串

alert(document.getElementById('myframe').src);
尝试:


其中myframe是框架的id

请参阅我的父url:localhost/web\u social和我的iframe url:localhost:8585/something在控制台中获取此错误:未捕获类型错误:无法读取未定义的htmlpage.html的属性“myframe”。html:121getiframeURL htmlpage.html:121onclick htmlpage.html:130 screanshot:适用于我,尝试以下操作:
alert(document.getElementsByTagName('iframe')[0].contentWindow.location.href)
document.getElementById("myframe").contentWindow.location.href