修改iframe超链接 [英] modify iframe hyperlinks
本文介绍了修改iframe超链接的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我可以使用javascript/jquery修改iframe的锚标记吗?我想修改iframe中的所有锚标签以添加target="_blank"
Can I modify an iframe's anchor tags with javascript / jquery? I want to modify all anchor tags within the iframe to add a target="_blank"
推荐答案
如果Iframe src与父页面不在同一个域中,则由于同源政策而不能.
If the Iframe src is not in the same domain as the parent page, you can't because of the same origin policy.
否则,您可以执行以下操作:
Otherwise, you can do this:
$("#iFrameName").contents().find("a").attr('target','_blank')
这篇关于修改iframe超链接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文