用单选框的选中与否来设置链接是否在新窗口中打开,实用效果 - 中国WEB开发者网络 (http://www.webasp.net) -- 网页特效 (http://www.webasp.net/javascript/) --- 用单选框的选中与否来设置链接是否在新窗口中打开,实用效果 (http://www.webasp.net/javascript/1/483.htm) |
| -- 发布日期: 2005-06-13 |
| <!-- 网页特效代码由[中国WEB开发者网络:http://www.ChinaWebDev.com]提供! --> <!-- 要实现此效果需要 1 个步骤: --> <!-- 第 1 步: --> <!-- 把下面的代码加到<BODY></BODY>区域中: --> <SCRIPT LANGUAGE="JavaScript"> <!-- //Enter "_blank" for new window (each time), "window2" for a set secondary window var newwindow="_blank" function hyperlinks(target){ if (target) where = newwindow; else where = "_self"; for (var i=0; i<=(document.links.length-1); i++){ if (target && where!="_blank") //DynamicDrive.com added routine- open window in set secondary window document.links[i].onclick=function(){ if (window.window2 && !window2.closed) window2.location=this.href else window2=window.open(this.href) window2.focus() return false } else{ if (newwindow=="window2") document.links[i].onclick = ""; document.links[i].target = where; } } } function inithyperlinks(){ //DynamicDrive.com added routine if (document.targetform.targetnew.checked) hyperlinks(true) } window.onload=inithyperlinks // --> </SCRIPT> <FORM name="targetform"><INPUT TYPE="checkbox" NAME="targetnew" ONCLICK="hyperlinks(this.checked)" checked> <b>在新窗口中打开链接</b></FORM> <a href=http://www.cctv.com>央视国际</a> |
| webasp.net |