请参阅下面的代码:我希望第1页提醒“# alert”.
这适用于C和FF,但不适用于IE :S。
页面1:
这是将要访问的页面。
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
</head>
<body>
<iframe src="http://page2.com/#testing"></iframe>
</body>
</html>页面2:
这是iframe的页面。
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
</head>
<body>
<script>
alert(window.location.hash);
</script>
</body>
</html>发布于 2012-03-29 09:31:51
尝试在IE中使用window.frameElement.contentWindow.location.hash
发布于 2012-04-21 11:25:22
我确认了这个问题!location.hash和window.location.hash只是空的,如果页面在IE9中处于跨域iframe (没有在旧版本中进行测试)!
https://stackoverflow.com/questions/9922616
复制相似问题