使用JQuery / Javascript访问iFrame URL [英] Access iFrame URL with JQuery / Javascript

查看:105
本文介绍了使用JQuery / Javascript访问iFrame URL的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个这样的页面......

I have a page like this...

<div>
<iframe id="mainContent">
<iframe id="littleBox">
</div>

我想这样做......

and I want to do this...

 $(".someButton").live('click', function() {
       alert(/*The URL That the Main Frame is ON*/);
 });

我发现: $(#mainFrame)。get(0 ).location.href ,但它不起作用...

I found this: $("#mainFrame").get(0).location.href, but it doesnt work...

另外,我需要它来返回当前的url,所以如果有人导航它周围应该返回它们所在的当前页面。

Also, I need it to return the current url, so if someone navigates around it should return the current page they are on.

推荐答案

好吧你的意思是你必须访问父亲的URL孩子iframe?

Okay so you mean you have to access the URL of the parent from the child iframe?

$("#mainFrame").get(0).contentWindow.location

这篇关于使用JQuery / Javascript访问iFrame URL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆