473,385 Members | 1,720 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

onClick firing to wrong window

139 100+
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
3 1891
acoder
16,027 Expert Mod 8TB
What does highlight() do?
Sep 5 '09 #2
ndeeley
139 100+
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
16,027 Expert Mod 8TB
Perhaps you want to prevent that from firing when the link is clicked.
Sep 8 '09 #4

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

Similar topics

5
by: Mike | last post by:
In my previous post, I wrote: > ... > GOAL: (very simple) Provide a hyperlink which, when clicked, > calls a javascript function which opens a new URL. > ... > PROBLEM: The following code...
7
by: Nick72 | last post by:
Hi, I've been reading through tons of posts regarding the problems people have encountered with getting javascript functions to trigger when called from onclick events... But so far, I haven't...
10
by: Eric-Sebastien Lachance | last post by:
Hey there, I decided to just create a 100% height and width div that filled the space over a background header image, and add an onclick event to redirect to the my index... Doesn't seem to work...
5
by: Michel | last post by:
Hi Group of helpers, Following snippet of code: <HTML> <HEAD> <script> function color(value) { alert(value);
17
by: dan_williams | last post by:
I have the following test web page:- <html> <head><title>Test</title> <script language="Javascript"> <!-- function fnTR() { alert("TR"); }
18
by: joaotsetsemoita | last post by:
Hello everyone, I'm having troubles assigning an onclick event to a cell. Im trying something like cursorPoint.cells.style.cursor = "hand"; cursorPoint.cells.width = "20";...
8
by: Dan Rumney | last post by:
All, I have a web page (copied below) with 3 images on it of fixed dimensions. Each image has a map associated with it In the maps, there are a number of areas with an onClick handler...
21
by: brucedodds | last post by:
I have an Access 2003 form bound to a SQL Server table via ODBC. Often clicking a button on the form has the effect of requerying the form rather than firing the OnClick event. Does anyone have...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.