惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

WordPress大学
WordPress大学
Microsoft Security Blog
Microsoft Security Blog
Security Archives - TechRepublic
Security Archives - TechRepublic
V
Visual Studio Blog
宝玉的分享
宝玉的分享
IT之家
IT之家
人人都是产品经理
人人都是产品经理
T
The Blog of Author Tim Ferriss
I
InfoQ
B
Blog RSS Feed
T
Threatpost
博客园_首页
M
MIT News - Artificial intelligence
Spread Privacy
Spread Privacy
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
Know Your Adversary
Know Your Adversary
U
Unit 42
Engineering at Meta
Engineering at Meta
C
Cyber Attacks, Cyber Crime and Cyber Security
月光博客
月光博客
Scott Helme
Scott Helme
T
Tor Project blog
有赞技术团队
有赞技术团队
AWS News Blog
AWS News Blog
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
Last Week in AI
Last Week in AI
S
Schneier on Security
Vercel News
Vercel News
博客园 - Franky
C
Cybersecurity and Infrastructure Security Agency CISA
L
LINUX DO - 热门话题
NISL@THU
NISL@THU
L
LangChain Blog
爱范儿
爱范儿
Google DeepMind News
Google DeepMind News
The GitHub Blog
The GitHub Blog
雷峰网
雷峰网
Latest news
Latest news
C
CXSECURITY Database RSS Feed - CXSecurity.com
Hugging Face - Blog
Hugging Face - Blog
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
www.infosecurity-magazine.com
www.infosecurity-magazine.com
G
GRAHAM CLULEY
S
Security Affairs
A
About on SuperTechFans
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
大猫的无限游戏
大猫的无限游戏
W
WeLiveSecurity
Cisco Talos Blog
Cisco Talos Blog
罗磊的独立博客

博客园 - 啊不才

【转载备用】Linux内核编译 幸运的Windows 7 Party 社区活动 jQueryinAction学习笔记——01 - 啊不才 - 博客园 django的字符替换问题 KB937061和KB947738多次安装问题 BlogEngine.Net的皮肤 [How Do I]系列学习笔记——001:学习一些技巧 继承类中override和new的区别 我提交的ACM题库的答案 『框架设计(第2版)CLR Via C#』学习笔记——使用is和as操作符来进行强制类型转换 调用Master页面上的属性 NotePad++很好用,但是我真的不想再用它了 BlogEngine的SQL Server数据库配置 关于asp:ScriptManager与Script代码块的位置关系问题 NHiBernate学习笔记(1) 使用JMail.NET时遇到的问题 ToString()方法与Convert.ToString()的差异 『框架设计(第2版)CLR Via C#』学习笔记——常量 【已解决,看后文】使用BlogEngine.net的扩展插件Silverlight Player Extension遇到的问题
如何在屏幕中央打开一个特定的窗口
啊不才 · 2009-02-22 · via 博客园 - 啊不才

在学习中,无意看到了如下代码,觉得很不错,收藏了。

source:How do I open a new window of a certain size?

   1:  <html>
   2:  <head>
   3:  <script>
   4:  <!--
   5:  function wopen(url, name, w, h)
   6:  {
   7:    // Fudge factors for window decoration space.
   8:    // In my tests these work well on all platforms & browsers.
   9:    w += 32;
  10:    h += 96;
  11:    wleft = (screen.width - w) / 2;
  12:    wtop = (screen.height - h) / 2;
  13:    // IE5 and other old browsers might allow a window that is
  14:    // partially offscreen or wider than the screen. Fix that.
  15:    // (Newer browsers fix this for us, but let's be thorough.)
  16:    if (wleft < 0) {
  17:      w = screen.width;
  18:      wleft = 0;
  19:    }
  20:    if (wtop < 0) {
  21:      h = screen.height;
  22:      wtop = 0;
  23:    }
  24:    var win = window.open(url,
  25:      name,
  26:      'width=' + w + ', height=' + h + ', ' +
  27:      'left=' + wleft + ', top=' + wtop + ', ' +
  28:      'location=no, menubar=no, ' +
  29:      'status=no, toolbar=no, scrollbars=no, resizable=no');
  30:    // Just in case width and height are ignored
  31:    win.resizeTo(w, h);
  32:    // Just in case left and top are ignored
  33:    win.moveTo(wleft, wtop);
  34:    win.focus();
  35:  }
  36:  // -->
  37:  </script>
  38:  </head>
  39:  <body>
  40:  <a href="page.html" target="popup"
  41:    onClick="wopen('page.html', 'popup', 300, 200); return false;">
  42:  Click here to open the page in a new window. </a>
  43:  </body>
  44:  </html>