我有一个这样的页面...
<div>
<iframe id="mainContent">
<iframe id="littleBox">
</div>
我想这样做...
$(".someButton").live('click', function() {
alert(/*The URL That the Main Frame is ON*/);
});
我找到了这个:$("#mainFrame").get(0).location.href
,但它不起作用...
另外,我需要它返回当前 url,所以如果有人在它周围导航,应该返回他们所在的当前页面。
最佳答案
好的,您的意思是您必须从子 iframe 访问父级的 URL?
$("#mainFrame").get(0).contentWindow.location
关于javascript - 使用 JQuery/Javascript 访问 iFrame URL,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3705594/