更改所有< a>标签在Windows商店应用中的iframe中的目标? [英] Change all <a> tag's target in iframe in windows store app?
本文介绍了更改所有< a>标签在Windows商店应用中的iframe中的目标?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
大家好,
我现在正在构建一个Windows应用商店应用并拥有一个在iframe中加载外部页面的页面。该页面具有< a>标记,当我点击我的iframe重定向到其href中的网址时。我想要所有< a>在iframe中标记打开浏览器而不是
的重定向本身,那么我该怎么办?
我想到的解决方案是改变所有< a>标记的目标为"_blank"但似乎我不能在iframe中做到这一点。
I now building a windows store app and having a page that load external page in the iframe. The page is having <a> tag and when I click that my iframe is redirect to the url in its href. I want all <a> tag in iframe to open the browser instead
of redirect itself, so how can I do that?
The solution I think of is change all <a> tag's target to "_blank" but it seem like I can't do that inside iframe.
谢谢你提前。
推荐答案
像这样:
var frame = document.getElementById("tab").contentDocument;
//Include in function or event.
var tags = frame.getElementsByTagName("a");
for (var i = 0; i < tags.length; i++) {
tags[i].target= '_blank';
}
希望这会有所帮助!
Hope this helps!
这篇关于更改所有< a>标签在Windows商店应用中的iframe中的目标?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文