Change target of all links inside an iframe to "_parent" jquery
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 firefo开发者_运维问答x 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.
It might be noted that you could do this without scripting anything with a base tag
<base target="_parent">
in the head.
精彩评论