对window.open进行封装, 使其更好用, 且更兼容, 很多人说window.open不兼容,其实不是, 因为不能直接执行, 必须通过用户手动触发才行;看代码:
代码如下 | 复制代码 |
var openWindow = function(url, options) { var str = ""; if (options) { options.height = options.height || 420; options.width = options.width || 550; options.left = options.left || ((screen.width - options.width) / 2); //默认为居中 options.top = options.top || ((screen.height - options.height) / 2); //默认为居中 for (var i in options) { //demo 1:新窗口打开 //demo 2:固定宽 并居中 |
时间: 2025-01-20 13:47:49