美文网首页
关于window.open的使用

关于window.open的使用

作者: LemonTree7 | 来源:发表于2023-03-23 17:26 被阅读0次

window.open()官网的说明是:窗口接口的open()方法将一个指定的资源加载到一个新的或现有的浏览环境中(即一个标签、一个窗口或一个iframe),并使用一个指定的名称。官网

window.open(url, target, windowFeatures)
open(iframeUrl, '_blank', params);
target:  '_blank' //_self, _blank, _parent, and _top
windowFeatures: scrollbars=no,resizable=no,status=no,location=no,toolbar=no,menubar=no,width=800,height=500,left=0,top=0,status=yes //popup

//如果需要居中,需要计算宽度距离
const l=(screen.availWidth-800)/2;
const t=(screen.availHeight-500)/2;
let params = `scrollbars=no,resizable=no,status=no,location=no,toolbar=no,menubar=no,width=800,height=500,left=${l},top=${t},status=yes`;
open(iframeUrl, '_blank', params);

相关文章

网友评论

      本文标题:关于window.open的使用

      本文链接:https://www.haomeiwen.com/subject/kouirdtx.html