Click to See Complete Forum and Search --> : Java script HELP!


*C*
10-28-2003, 03:49 PM
Hi,
I am having trouble with java script (go figure) and need some help. Here is what I have thus far:
<html>
<head><title></title>
<script language="JavaScript">
<!--

//-->
</script>
</head>
<body>
<input name="site name" value="http://">
<input type=button value="Open"><br><br>
<input type=checkbox name="new">&nbsp&nbsp&nbsp&nbsp&nbsp Open in same Window
</body>
</html>
As you can see I have no java script. I do not know where to begin. What I have is an input box where a user can put any website address. Then there is a button that when clicked needs to open the website in a new browser. There is also a box that when checked has to open the site in the same browser. I have all that and it looks nice but I need the java script to make it WORK. Any help would be very much appreciated.

fredmv
10-28-2003, 04:01 PM
Welcome to the forums. :)

Try this:<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd" xml:lang="en">

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>untitled</title>
<meta http-equiv="Content-Type" content="application/xhtml+xml; charset=iso-8859-1" />
<script type="text/javascript">
//<![CDATA[
var f = null;

function go()
{
( f.c.checked ) ? location.href = f.t.value : window.open( f.t.value, '', '' );

return false;
}

onload = function()
{
f = document.getElementById( 'f' );
f.t.focus();
}
//]]>
</script>
</head>
<body>
<div>
<form id="f" onsubmit="return go();">
<input type="text" style="width: 200px;" value="http://" name="t" />
<input type="checkbox" name="c" /> Open in this browser.
<hr />
<input type="submit" value="Go" />
<input type="reset" value="Reset" />
</form>
</div>
</body>
</html>I hope that helps you out.