点击事件未在鼠标越来越缩放图像上的同一选项卡/窗口中打开

发布于 2025-02-07 03:37:36 字数 1912 浏览 0 评论 0原文

我正在尝试在同一选项卡/窗口上打开网页,点击缩放图像。我尝试了_ self,但它不起作用。另外,我正在使用Google网站开发一个简单的网站。似乎很容易,但没有得到答案,我无法解决问题。附加我的代码。

<!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>

这是我目前的情况:

这就是我期望的:

”在此处输入图像描述”

I am trying to open a web page on same tab/window on-clicking a zoom-over image. I tried _self but it is not working. Also, I am using Google Sites to develop a simple website. It seems easy but not getting the answer and I'm unable to solve the issue. Attaching my code.

<!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>

This is my current situation:
enter image description here

And this is what i am expecting:

enter image description here

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

荆棘i 2025-02-14 03:37:36

我的理解是,您打算在用户单击它时打开页面内的弹出窗口。这可以如下:

1。创建一个iframe,

需要创建iframe这样的

<iframe id="mypopup" style="display:none;"></iframe>

function openIFrame(url) {
    let myPopup = document.getElementById("mypopup");
    mypopup.style.display = "block";
    mypopup.src = url;
}

onclick="openIFrame(this.href); return false;"

在你的锚点。

My understanding is that you intend to open a popup inside your page when the user is clicking on it. This can be achieved as follows:

1. Create an iframe

You will need to create an iframe like this:

<iframe id="mypopup" style="display:none;"></iframe>

2. Create a function that opens it with a URL

function openIFrame(url) {
    let myPopup = document.getElementById("mypopup");
    mypopup.style.display = "block";
    mypopup.src = url;
}

3. Have an onclick that executes it

Something like

onclick="openIFrame(this.href); return false;"

in your anchor.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文