Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我正在将 iframe 用于我不拥有的单独域,但我希望链接保留在我的 iframe 中,但它们使用 target=_blank
从我搜索的内容来看似乎不可能,但我想我会在放弃之前问
理论上,您可以使用父页面中的一些 JavaScript 来连接子页面,使用一些伪代码$("#iframeID").contents()来获取框架内容,然后使用类似于$("a").target = "_self"您需要查找 jQuery 以获取确切语法的东西。
$("#iframeID").contents()
$("a").target = "_self"
问题是这在跨域上不起作用,除非CORS