如何从iframe src获取哈希值?

时间:2011-04-21 07:51:18

标签: javascript jquery iframe cross-domain

当我执行iframe.src时,我的iframe有一个带有哈希值的url它只是给了我一个url而没有从其他域附加的哈希值。我可以用哈希读取整个网址。

2 个答案:

答案 0 :(得分:2)

不太可能是出于安全限制 - 我很惊讶你甚至可以获得网址

你能展示代码吗?

听起来像是How to get iframe contentWindow height in cross domain

的副本

答案 1 :(得分:2)

var contentWnd = $('iframe').attr('contentWindow');
var hash = contentWnd.window.location.hash;

适应这个答案:Get url from iframe and update hash in browser url

相关问题