1

我想在嵌入标签上添加 onclick 事件,但问题是,它在 chrome 上不起作用,并且处理程序不起作用。除了 onclick 事件 mouseover 和 mouseleave 正在工作。这里是代码 HTML

<embed src="http://localhost/credit-app1/" onclick="increaseSize()" onload="bottomRight()">

JAVASCRIPT

function increaseSize(){
    var embedtag = document.querySelector("embed");
    if(embedtag.style.width == "400px"){
        embedtag.style.width = "100px";
        embedtag.style.height = "100px";
    }else{
        embedtag.style.width = "400px";
        embedtag.style.height = "500px"; 
    }
    console.log(embedtag)
}
4

1 回答 1

0

您可以使用悬停效果使用纯 css 来完成它:

embed:hover {
  transform: scale(2.5);
}

我不确定它应该如何使用onclick(),因为里面的内容永远不会有点击事件......

或者:

您可以尝试<div>在嵌入的内容上放置一个透明的:

<div style="height: 100px; width: 100px; position: absolute; top: 0; background-color: transparent;" onclick="increaseSize()"></div>
<embed src="http://localhost/credit-app1/" onload="bottomRight()" style="position: relative;">

在 JavaScript 中,您也需要调整 div 的大小。

于 2021-11-24T10:05:09.237 回答