Click to See Complete Forum and Search --> : How to ?? Open a link
Maisy
02-09-2003, 12:56 PM
Simple question...
I have a link on my page, I want the current page to stay open, and the link to open up in a NEW WINDOW. How do I accomplish this? I know it's something easy, but I can't figure it out for the life of me!
Thanks for your help in advance!
Maisy
Charles
02-09-2003, 01:01 PM
<a href="http://www.w3.org/" onclick="window.open(this.href); return false">W3C</a>
And see http://developer.netscape.com/docs/manuals/js/client/jsref/window.htm#1202731 for details.
Nevermore
02-09-2003, 01:07 PM
Here is the script. Just replace your_url_here (in the anchor tag) with the URL you want in the new window. You can make multiple links like this, and put a different URL in each function call without making the script any more complicated.
PM me if you need any help with the script.
<html>
<head>
<title>Javascript Window Opener</title>
<script language="Javascript">
<!--
function newWindow(destination){
window.open(destination);
}
//-->
</script>
</head>
<body>
<a href="javascript:newWindow('your_url_here')">Open New Page</a>
</body>
</html>
Charles
02-09-2003, 01:09 PM
If you follow the example presented immediately above you will find that your link does nothing for the one in ten users that use no JavaScript. My method, posted further up, will always work.
Nevermore
02-09-2003, 01:14 PM
Surely the best solution would be a javascript checker, so that people with javascript could opena new window, and those without could use the open one. BTW, sorry about replying after Charles. He posted while i was writing the reply.
Charles
02-09-2003, 01:19 PM
Originally posted by cijori
Surely the best solution would be a javascript checker, so that people with javascript could opena new window, and those without could use the open one. Why would you use a checker when my method when the method that I have demonstarted will geive the same results with less work? And how are you going to get your "javascript [sic] checker" to work on borwsers that do not support scripting?