如何使iframe成为标签的href,并在新标签页中打开iframe?我不希望在单击链接之前显示任何iframe。如果无法实现,请给我其他代码显示链接,但是当有人单击它时,它将在新标签上打开一个iframe,并为该iframe设置src值。
答案 0 :(得分:0)
这个问题有点不清楚,因此在处理新打开的标签上的iframe时,我的答案还没有完成,但这应该是您要查找的代码:
function openNew(src){
window.open(
'yournewpage.php?iframesrc=' + src,
'_blank' // <- This is what makes it open in a new window.
);
}
#color{
background:green;
width:100px;
height:50px;
}
<h3>
this is your link, and when clicked on we run javascript opening a new page(_blank) and we add any type of link in the onclick and pass it into the link on the new tab, then you can grab that src from the link and add it into a new iframe on the new tab
</h3>
<div id="color" onclick="openNew('https://stackoverflow.com')">
<h3>
link
</h3>
</div>