将iframe中所有链接的目标更改为“_parent” jQuery的 [英] Change target of all links inside an iframe to "_parent" jquery
问题描述
<$ p我试图设置目标到一个iframe中的所有链接到_parent使用jquery,但我不知道如何做到这一点,任何人都可以帮助我? $ p>
< script src =jquery-1.5.2.min.js>
$('a')。target(_ parent);
< / script>
< iframe src =http://google.comframeborder =0>< / iframe>
我这样做是因为我想自定义我的firefox 4主页来显示Google的起始页还原会话按钮附近的登录链接,我几乎这样做,但我不想打开新的链接或搜索iframe内。
谢谢 p>
PS如果有没有使用jQuery的另一种方式,它会很好。
$('a')。attr(target,_parent);
jQuery中没有方法叫做 target()
;)阅读jQuery中的 attr
方法 - http: //api.jquery.com/attr/
为此,您应该有两个< script / >
标签分开。
< script src =jquery-1.5.2.min。 jstype =text / javascript>< / script>
< script type =text / javascript>
$('a')。attr(target,_parent);
< / script>
正因如此,您不能访问 iframe的内容
,如果其内容托管在与其父文档不同的域中。
im trying to set the target to all links inside an iframe to "_parent" using jquery but im not sure how to do it, can anyone help me?
<script src="jquery-1.5.2.min.js">
$('a').target("_parent");
</script>
<iframe src="http://google.com" frameborder="0"></iframe>
Im doing this because I want to customize my firefox 4 homepage to show me the Google's start page with the restore session button near the "Sign in" link, and I almost do it but i don't wanna open the new links or searches inside the iframe.
Thanks
P.S. If is there another way without using jquery it would be great.
It's
$('a').attr("target", "_parent");
There's no method in jQuery called target()
;) Read about the attr
method in jQuery - http://api.jquery.com/attr/
To go along with that, you should have the two <script />
tags separate.
<script src="jquery-1.5.2.min.js" type="text/javascript"></script>
<script type="text/javascript">
$('a').attr("target", "_parent");
</script>
And just so you know, you cannot access the content of an iframe
if its content is hosted on a different domain than its parent document.
这篇关于将iframe中所有链接的目标更改为“_parent” jQuery的的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!