找回密码
 注册账户
查看: 1817|回复: 1

Open browser pop-up windows by JavaScript

[复制链接]
admin 发表于 2008-3-8 02:44:43 | 显示全部楼层 |阅读模式
Use this script to open browser pop-up windows when you click a link or an image

The script can position the new window at a given x and y position on the screen, you can specify window width, height and you can specify what other items to apear or to hide on the window (buttons, status bar, etc)

Copy and paste this code in the <head>...</head> area of your code:
  1. <script language="JavaScript" type="text/javascript">var popUpWin=0;function popUpWindow(URLStr, left, top, width, height){  if(popUpWin)  {    if(!popUpWin.closed) popUpWin.close();  }  popUpWin = open(URLStr, 'popUpWin', 'toolbar=no,location=no,directories=no,  status=no,menubar=no,scrollbars=no,resizable=no,copyhistory=yes,width='+width+  ',height='+height+',left='+left+', top='+top+',screenX='+left+',  screenY='+top+'');}</script>
复制代码
Then add this code to a normal href link (inside the <a> tag):
onclick="javascript:popUpWindow('http://www.thewebhelp.com','200','200','320','240')"

So that your link looks like this:
  1. <a href="#" onclick="javascript:popUpWindow('http://www.thewebhelp.com','200','200','320','240')">Open a pop-up</a>
复制代码
amasan 发表于 2009-2-7 08:00:04 | 显示全部楼层
您需要登录后才可以回帖 登录 | 注册账户

本版积分规则

存档|黑屋|手机|网络实验室 本站服务器由美国合租以及IDCLayer国际数据提供!!!

GMT+8, 2026-6-5 11:24 , Processed in 0.009496 second(s), 6 queries , Gzip On, Redis On.

Powered by Discuz! X3.5

© 2001-2025 Discuz! Team.

快速回复 返回顶部 返回列表