您好,是否可以在新打开的窗口中删除“关于:”空白?因为我正在为我的应用程序弹出窗口创建一个新窗口,并将在其上创建一些内容。我下面有一个简单的示例。我的问题是 URL 上有“about:blank”,是否可以删除它?
<html>
<body>
<button onclick="myFunction()">Try it</button>
<script>
function myFunction() {
var myWindow = window.open("", "", "width=200,height=100");
myWindow.document.write('<html><head> <title>Sample</title><link rel="stylesheet" type="text/css" href="css/newsCSSWindow.css"></head><body>');
myWindow.document.write("Sample Window");
myWindow.document.write('</body></html>');
}
</script>
</body>
</html>
Run Code Online (Sandbox Code Playgroud) Console.log 打印两次。我曾尝试使用 e.stopPropagation()、e.preventDefault() 和 .stop()。这是行不通的。console.log 应该只触发一次
$('html').keyup(function (e) {
if (e.keyCode == 46) {
console.log("delete press");
e.stopPropagation();
e.preventDefault();
}
});
Run Code Online (Sandbox Code Playgroud)