onClick触发到错误的窗口

嗨,
我有一个嵌套在表单中的链接,当单击它时,应该会打开一个新窗口.在这样做的同时,它还会在现有的父窗口中打开页面.
然而,代码不是我写的,当不放在表单中时,它可以正常工作.是否将窗体的onClick事件与窗口的onClick事件混淆?
标题代码如下:

选择 | 换行 | 行号
  1. <script language="javascript" type="text/javascript">
  2. <!--
  3. /****************************************************
  4.      Author: Eric King
  5.      Url: http://redrival.com/eak/index.shtml
  6.      This script is free to use as long as this info is left in
  7.      Featured on Dynamic Drive script library (http://www.dynamicdrive.com)
  8. ****************************************************/
  9. var win=null;
  10. function NewWindow(mypage,myname,w,h,scroll,pos){
  11. if(pos=="random"){LeftPosition=(screen.width)?Math.floor(Math.random()*(screen.width-w)):100;TopPosition=(screen.height)?Math.floor(Math.random()*
  12.  
  13. ((screen.height-h)-75)):100;}
  14. if(pos=="center"){LeftPosition=(screen.width)?(screen.width-w)/2:100;TopPosition=(screen.height)?(screen.height-h)/2:100;}
  15. else if((pos!="center" && pos!="random") || pos==null){LeftPosition=0;TopPosition=20}
  16. settings='width='+w+',height='+h+',top='+TopPosition+',left='+LeftPosition+',scrollbars='+scroll+',location=no,directories=no,status=no,menubar=no
  17.  
  18. ,toolbar=no,resizable=no';
  19. win=window.open(mypage,myname,settings);}
  20. // -->
  21. </script>

和新窗口的链接代码:

选择 | 换行 | 行号
  1. <a href="http://marlin/engeastl/scripts/RepairWorkshops/AddNew2.cfm" 
  2.  
  3. onclick="NewWindow(this.href,'UserAccess','720','340','yes','center');return false" onfocus="this.blur()" class="recordno" style="font-size: 
  4.  
  5. 1.1em;">Add a New Site</a>

以及链接嵌套的表单的onClick事件:

选择 | 换行 | 行号
  1. <form action="Devaction_add.cfm" method="post" name="form" onKeyUp="highlight(event)" onClick="highlight(event)" 
  2.  
  3. onsubmit="return formCheck(this);">

有谁能帮忙吗?
谢谢
尼尔

# 回答1


Highlight()有什么作用?
# 回答2


这是一个当光标进入字段时会突出显示该字段的Java脚本函数,这样用户就可以知道他们正在填写的是哪一位.
# 回答3


也许您想要防止在单击链接时触发该链接.

标签: Javascript

添加新评论