Click to See Complete Forum and Search --> : Need help


Login_Here
07-03-2003, 06:22 AM
Im quite new to javascript so i need some help.
If i want to make a button that is linked to a website
and open it in a new window how do i do
For example i write

<head>

<SCRIPT LANGUAGE="JavaScript">

<-- Begin
function goToURL() { window.location = "http://www.google.com; }
// End -->
</script>

</head>

<body>

<form>
<input type=button value="Google" onClick="goToURL()">
</form>

</body>

What should i write to make the website open in a new window?

And what do i write if i want many buttons linked to different websites?

Charles
07-03-2003, 06:27 AM
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta name="Content-Script-Type" content="text/javascript">
<title>Example</title>
<form action="http://www.w3.org/" onsubmit="window.open(this.action, 'child', 'height=400,width=300'); return false">
<div>
<button type="submit">the W3C</button>
</div>
</form>

requestcode
07-03-2003, 06:29 AM
To have it open in a new window and use it for many buttons you would change your function to this:
function goToURL(linkid) { window.open(linkid,"win1"); }
Then your buttons like this:
<input type=button value="Google" onClick="goToURL('http://www.google.com')">

When you click on the button the function goToURL is called and the web page is passed to the function and the variable linkid holds this value.

Login_Here
07-03-2003, 06:43 AM
Thank you, Charles code works in the browser i use called Crazy Browser but doesnt work in IE, in crazy browser i can see the top of the website but nothing else. And requestcode's code doesnt work at all:(