gpt4 book ai didi

javascript - Node webkit : Cut/copy/paste right click context menu and iframe

转载 作者:行者123 更新时间:2023-11-30 17:28:55 29 4
gpt4 key购买 nike

有没有关于如何做到这一点的引用实现?

整个应用程序都有一个带有我无法修改的第三方内容的 iframe。我能够在空白应用程序中设置上下文菜单,但当 iframe 占据整个窗口时它不会出现。

(我使用 $(document).on("contextmenu", ..)

如何让它在 iframe 中也能正常工作?

最佳答案

您应该将监听器附加到 iframe 的内容窗口。这是一个示例代码,我认为它应该符合您的需要。

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf8">
<title></title>
<style type="text/css">
#gframe{
width: 100%;
height: 100%;
left: 0px;
top: 0px;
position: absolute;
}
</style>
<script type="text/javascript">
var appendContextmenuListener = function(){
var gframe = document.getElementById('gframe');
var subWindow = gframe.contentWindow;
var subDocument = subWindow.document;
subDocument.oncontextmenu = function(){
console.log(1);
}
};
</script>
</head>
<body>
<iframe id="gframe" src="https://www.google.com.hk"
onload="appendContextmenuListener()"></iframe>
</body>
</html>

关于javascript - Node webkit : Cut/copy/paste right click context menu and iframe,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23615844/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com