Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

onClick open in original window: HELP!!

Status
Not open for further replies.

VatsaLoid

Technical User
Nov 11, 2006
1
GB
I press a button.

A popup opens, showing me a list of links.

I click on a link.

The popup closes, and the new link opens in a new window at the same time.

what should I put instead of onClick=window.open(' or make any changes anywhere else, so that the link I click on opens in the original window where I pressed the button to open the popup?

Also, how should I convert the checkbox links to the normal <a href> ones??

here s the code:
Code:
<html>
<head>
<script language="JavaScript" type="text/javascript">
<!-- Copyright 2001, Sandeep Gangadharan -->
<!-- For more free scripts go to [URL unfurl="true"]http://sivamdesign.com/scripts/[/URL] -->
<!--
var X = 200;  // change the # at the left for a fixed X co-ordinate to accommodate browsers other than IE or NS
var Y = 200;  // change the # at the left for a fixed Y co-ordinate to accommodate browsers other than IE or NS

if (navigator.appName.indexOf("Netscape")!=-1) {
document.captureEvents(Event.MOUSEMOVE)
function getcoords(e) {
X = parseInt(e.screenX) - 80;  // change the # at the left to further adjust the left-margin depending on the size of the window
Y = parseInt(e.screenY) - 60;  // change the # at the left to further adjust the top-margin depending on the size of the window
return true;}  
document.onmousemove = getcoords;

function openWin() {

if (navigator.appName.indexOf("Microsoft")!=-1) {
X = parseInt(event.screenX) - 80;  // change the # at the left to further adjust the left-margin depending on the size of the window
Y = parseInt(event.screenY) - 60; }  // change the # at the left to further adjust the top-margin depending on the size of the window

		display=window.open('','NewWin','menubar=0,location=no,status=no,directories=no,toolbar=no,scrollbars=yes,height=110,width=190')
		message="<font face='verdana, arial, helvetica, san-serif' size='2'><form>";
		message+="<input type='checkbox' onClick=window.open('[URL unfurl="true"]http://www.microsoft.com/','')[/URL] onBlur='window.close();' />Microsoft Corp.<br />";
		message+="<input type='checkbox' onClick=window.open('[URL unfurl="true"]http://home.netscape.com/','')[/URL] onBlur='window.close();' />Netscape Corp.<br />";
		message+="<input type='checkbox' onClick=window.open('[URL unfurl="true"]http://www.macromedia.com','')[/URL] onBlur='window.close();' />Macromedia Inc.<br />";
		message+="<input type='checkbox' onClick=window.open('[URL unfurl="true"]http://www.symantec.com','')[/URL] onBlur='window.close();' />Symantec Corp.<br />";
		message+="</form></font>";
		display.moveTo(X,Y);
		display.document.write(message); }
}
// -->
</script>
</head>
<body>
<font face="verdana, arial, helvetica, san-serif" size="2">
  <form><input type="button" value="Some Links" onClick="openWin()" /></form>
</font>
</body>
</html>

thanks,

VatsaL
 
[1] Add these two lines to tamper moz hourglass pending document write.
[tt]
display=window.open('','NewWin','menubar=0,location=no,status=no,directories=no,toolbar=no, scrollbars=yes,height=110,width=190')
[blue]display.document.open();[/blue]
//etc etc...
display.document.write(message);
[blue]display.document.close();[/blue] }
[/tt]
[2] To change the behaviour as asked, change every line of window.open() to this.
[tt]
[red]//[/red]message+="<input type='checkbox' onClick=window.open(' onBlur='window.close();' />Microsoft Corp.<br />";
message+="<input type='checkbox' onClick=[blue]\"window.opener.document.location='[/blue] onBlur='window.close();' />Microsoft Corp.<br />";
//corresponding changes for other checkbox lines
[/tt]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top