【发布时间】:2015-11-14 19:06:05
【问题描述】:
我正在让一个网页在占据整个屏幕的 iframe 中加载另一个网页。我有 2 个 div 彼此重叠。这些 div 实际上是指向新 url(动作)的锚点。我想要做的是,一旦单击任何 div,就会启动一个 onclick 事件,该事件将转到该锚 href 中指定的 url,然后重新加载初始 index.html 页面。我的班级正在研究当地环境,教我们一种叫做点击劫持的东西。以下是我当前的 html。
我遇到的问题是我可以让锚点点击转到我想要的 url,但是我不再在我的 index.html 中。是否可以在新窗口中打开引用的链接,加载后关闭新窗口,然后刷新 index.html 页面。一旦完成隐藏被点击的 div,因为“第二个”div 隐藏在最顶部的可点击 div 后面。
<html>
<head>
</head>
<body>
<center>
<!-- Two anchor divs that are clickable and on top of each other -->
<div id="secondDiv">
<a href="http://www.2ndURL.com" id="m2">
<div id="2" style="position:absolute;top:195px;left:10px;width:10000px;height:200px;">
<iframe>
</iframe>
</div>
</a>
</div>
<div id="firstDiv">
<a href="#" id="m1" onclick="myFunction(); return false;">
<div id="1" style="position:absolute;top:195px;left:10px;width:10000px;height:200px;">
<iframe>
</iframe>
</div>
</a>
<!-- Main iFrame where user interacts -->
</div>
<iframe id="new" src="http://www.mywebpage.com" style="opacity:1.0;width:100%;height:100%;">
</iframe>
</center>
</body>
<script>
function myFunction(){
var newWindow = window.open("http://www.actionURL");
newWindow.close()
var myWindow = window.open("file:///home/seed/Desktop/index.html", "_self");
}
</script>
</script>
</html>
TLDR:
- 在网页中加载 iframe
- 点击指向新网址的页面上的锚 div
- 加载该网址,加载后返回 index.html(全部在一个选项卡中)(步骤 1)
- 隐藏选择的锚 div -- 允许第二个锚 已点击
感谢您的帮助。
【问题讨论】:
标签: javascript jquery html css iframe