google-chrome - 有没有办法检测在 iframe 中单击的链接,而不是打开新选项卡,而是将 iframe src 更改为该链接?
问题描述
这是代码和链接。提前致谢。 https://codepen.io/Vanceagher/pen/ExYpYxq?editors=1100
<html>
<head>
<stlyle>
html, body {
padding: 0;
margin: 0;
background-color: #333;
}
iframe {
width: 100vw;
height: 80vh;
padding-top: 5vh;
}
.stuff {
height: 5vh;
}
#URL {
border-radius: 10px;
width: 25vw;
}
.frmSubmit {
border-radius: 10px;
}
#btn {
border-radius: 10p
}
</style>
<title> iFrame </title>
<script language="javascript">
function LoadPage(){
var objFrame=document.getElementById("myIframe");
objFrame.src=document.getElementById("URL").value;
}
</script>
</head>
<body>
<div ID="stuff">
<div style="Clear:both;">
<input type="text" value="https://www.bing.com" class="frmUrlVal" ID="URL">
<input type="submit" class="frmSubmit" value="Go" onclick="LoadPage()">
<input type="button" VALUE="< < Back " onClick="myIframe.history.back()">
<input type="button" VALUE="Forward > >" onClick="myIframe.history.forward()">
</div>
</div>
<iframe sandbox="allow-same-origin allow-scripts allow-pointer-lock allow-forms" align="center" src="https://www.bing.com" frameborder="no" scrolling="yes" name="myIframe" id="myIframe"></iframe>
</body>
</html>
谢谢!废话
解决方案
推荐阅读
- sql - where IN 子句中的分组函数
- matlab - 如何在matlab中绘制体积切片
- python - 如何使用 Oauth2 进行会话并发出可重复的请求?
- javascript - Jsxgraph如何嵌入Katex而不是Mathjs
- sql - 根据某种顺序,为源表中的每一行从目标表中获取一行
- vue.js - VueJS/vuex 应用设计题——如何用getter初始化本地数据
- go - 构建 go 项目时忽略 ldflags
- jsf - 下载文件后重新渲染组件
- angular - websocket 传输在带有 NestJS(仅长轮询)的谷歌云应用程序引擎标准上不起作用,在 flex 环境中工作
- julia - 在 Julia 中可视化一维随机游走