我试图打开一个网页在同一选项卡/窗口上,点击一个变焦图像。我试过_self,但它不起作用。此外,我正在使用谷歌网站开发一个简单的网站。这似乎很容易,但得不到答案,我无法解决这个问题。附加我的密码。
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<style>
* {
box-sizing: border-box;
}
.zoom[href] {
padding: 2px;
transition: transform .3s;
width: 150px;
height: 81px;
margin: 0 auto;
overflow: hidden;
}
.zoom:hover {
-ms-transform: scale(1.3); /* IE 9 */
-webkit-transform: scale(1.3); /* Safari 3-8 */
transform: scale(1.3);
}
::-webkit-scrollbar {
width: 0px; /* remove scrollbar space /
background: transparent; / optional: just make scrollbar invisible /
}
/ optional: show position indicator in red */
::-webkit-scrollbar-thumb {
background: #FF0000;
}
</style>
<script type="text/javascript">
var windowObjectReference = null; // global variable
function openRequestedPopup(url, windowName) {
if(windowObjectReference == null || windowObjectReference.closed) {
windowObjectReference = window.open(url, windowName, "_self");
} else {
windowObjectReference.focus();
};
}
</script>
</head>
<body>
<div class="zoom">
<a href="https://www.google.com" onclick="openRequestedPopup(this.href, this.target); return false;">
<img src="https://via.placeholder.com/250" alt="Our Performance" styles="width:100%">
</a>
</div>
</body>
</html>
这就是我的现状:

这就是我所期待的:

发布于 2022-06-14 16:28:52
我的理解是,当用户单击页面时,您打算在页面中打开一个弹出。实现这一目标的办法如下:
1.创建一个iframe
您需要创建这样一个iframe:
<iframe id="mypopup" style="display:none;"></iframe>2.创建一个用URL打开它的函数
function openIFrame(url) {
let myPopup = document.getElementById("mypopup");
mypopup.style.display = "block";
mypopup.src = url;
}3.点击鼠标执行它。
有点像
onclick="openIFrame(this.href); return false;"在你的锚上。
https://stackoverflow.com/questions/72605162
复制相似问题