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

推荐订阅源

Engineering at Meta
Engineering at Meta
博客园_首页
H
Help Net Security
WordPress大学
WordPress大学
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
罗磊的独立博客
博客园 - 三生石上(FineUI控件)
B
Blog
I
InfoQ
SecWiki News
SecWiki News
T
Tailwind CSS Blog
Spread Privacy
Spread Privacy
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
V
Vulnerabilities – Threatpost
N
Netflix TechBlog - Medium
P
Palo Alto Networks Blog
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
Vercel News
Vercel News
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
K
Kaspersky official blog
M
MIT News - Artificial intelligence
S
Schneier on Security
T
Threat Research - Cisco Blogs
F
Fortinet All Blogs
Cyberwarzone
Cyberwarzone
Scott Helme
Scott Helme
aimingoo的专栏
aimingoo的专栏
Martin Fowler
Martin Fowler
MyScale Blog
MyScale Blog
The Cloudflare Blog
Recent Announcements
Recent Announcements
Security Latest
Security Latest
G
GRAHAM CLULEY
IT之家
IT之家
Y
Y Combinator Blog
The Last Watchdog
The Last Watchdog
腾讯CDC
Google DeepMind News
Google DeepMind News
V
V2EX
S
Securelist
TaoSecurity Blog
TaoSecurity Blog
B
Blog RSS Feed
S
SegmentFault 最新的问题
博客园 - 叶小钗
P
Proofpoint News Feed
云风的 BLOG
云风的 BLOG
Project Zero
Project Zero
G
Google Developers Blog
Google DeepMind News
Google DeepMind News
F
Full Disclosure

博客园 - 啊不才

【转载备用】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>