By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,377 Members | 1,672 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,377 IT Pros & Developers. It's quick & easy.

onClick firing to wrong window

100+
P: 139
Hi,

I've got a link nested inside a form which, when clicked, should open a new window. Whilst it's doing this it also opens the page in the existing parent window as well.

I didn't write the code however, and it worked when not placed in a form. Is the onClick event of the form getting confused with the onclick event of the window?

Heres the header code:

Expand|Select|Wrap|Line Numbers
  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>
And the link code for the new window:
Expand|Select|Wrap|Line Numbers
  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>
And the onClick event of the form in which the link is nested:

Expand|Select|Wrap|Line Numbers
  1. <form action="Devaction_add.cfm" method="post" name="form" onKeyUp="highlight(event)" onClick="highlight(event)" 
  2.  
  3. onsubmit="return formCheck(this);">
Can anyone help?
Thanks
Neil
Aug 13 '09 #1
Share this Question
Share on Google+
3 Replies


acoder
Expert Mod 15k+
P: 16,027
What does highlight() do?
Sep 5 '09 #2

100+
P: 139
It's a javascript function that highlights a field when the cursor enters it, so the user knows what bit they are filling out.
Sep 7 '09 #3

acoder
Expert Mod 15k+
P: 16,027
Perhaps you want to prevent that from firing when the link is clicked.
Sep 8 '09 #4

Post your reply

Sign in to post your reply or Sign up for a free account.