2009年2月22日

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

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>
posted @ 2009-02-22 13:31 啊不才 阅读(70) 评论(0) 编辑

导航

公告


英文名:Bright Chen
MSN:czhgary@hotmail.com
QQ:15095488
Email:biser007@gmail.com

Bright Chen 的个人主页
Bright Chen 的Facebook资料
创建您的徽章


小D划词查询功能:......


跟小D每日学口语,别偷懒啊~!!


《荀子·劝学》:“不积跬步,无以致千里;不积小流,无以成江海。”

洛阳.NET俱乐部 MSN群: group114825@msnzone.cn

欢迎光临:


IT新闻:

昵称:啊不才
园龄:7年6个月
粉丝:5
关注:10
<2009年2月>
25262728293031
1234567
891011121314
15161718192021
22232425262728
1234567

统计

搜索

 
 

常用链接

最新随笔

我的标签

随笔分类(39)

随笔档案(38)

相册

Good Web

Super Bloger

积分与排名

最新评论

阅读排行榜

评论排行榜

推荐排行榜