【发布时间】:2014-06-30 23:46:06
【问题描述】:
我希望如果有人单击链接,则仅在该页面上(该人单击链接)另一个页面应作为嵌入页面或 i 框架打开。如何使用 html 或 javascript 在我的网站上执行此操作?
【问题讨论】:
-
使用 CSS(位置、z-index 等)[w3schools.com/css/css_positioning.asp]
标签: javascript html iframe web embed
我希望如果有人单击链接,则仅在该页面上(该人单击链接)另一个页面应作为嵌入页面或 i 框架打开。如何使用 html 或 javascript 在我的网站上执行此操作?
【问题讨论】:
标签: javascript html iframe web embed
试试这个,但我不确定它是否有效。 JSFiddle - link
编辑: HTML
<body>
<div id="box">
<a href="javascript:show();" >Link</a>
</div>
<div id="box2">
<iframe src="" id="frame" width=100% height=100%></iframe>
<div id="close"><input type="button" onclick="closeIframe()" value="X" /></div>
</div>
</body>
Javascript
function show()
{
box= document.getElementById("box");
box.style.visibility="hidden";
frame=document.getElementById("box2");
frame.style.visibility="visible";
}
function closeIframe()
{
box2=document.getElementById("box2");
box2.style.visibility="hidden";
box= document.getElementById("box");
box.style.visibility="visible";
}
CSS
#box
{
background-color:yellow;
}
#box2
{
position:absolute;
top:7px; //here i've set 7px but you cant set what you want
visibility:hidden;
}
#close
{
position:relative;
left:100%;
width:50px;
top:-160px;
}
【讨论】: