功能,在关闭浏览器时打开几个随机大小和位置的新窗口

function to open a few new windows of random sizes and locations upon closing the browser

本文关键字:随机 几个 位置 窗口 新窗口 浏览器 功能      更新时间:2023-09-26

function getRandomInt(min, max) { return Math.floor(Math.random() * (max - min + 1)) + min;} window.onbeforeunload = exit function exit(){ for(var i=0; i<5; i++) { var a = getRandomInt(101, 1500); var b = getRandomInt(101, 1500); var c = getRandomInt(1, 1500); var d = getRandomInt(1, 1500); window.open('Site.html', 'newwindow', 'width = a, height = b, top = c, left = d');} return空'

你能把一个变量传给window.open吗?

您需要在窗口中组合toString(intVar)和"+"(串联)运算符。打开规范参数。(括号内的第3位)

这似乎是一种邪恶的动机。这在15年前就奏效了。人们现在知道了关闭东西的快捷键。另外,不要那样做。