I must be stupid-- JavaScript help

I made a simple frameset for browsing where one frame has a list of ampersand HTML characters and a form whose code you see below. All I want to do is hit the submit button and have it tell the other frame to open the damn URL. for some reason it looks for the url I type in the textbox on my local hard drive, even though I explicitly type out “http://” and so on. (the other frame’s name is “theBrowser” for clarity…


<body bgcolor="#ffffff" text="#000000" id=all>
<script language="JavaScript">
<!--
function getURL() {
	var theURL = document.fetcher.URL;
	parent.theBrowser.location = theURL;
	}
// -->
</script>
<form name="fetcher" onSubmit="getURL()">
<div align="center">
<input type="text" name="URL" size=75 maxlength=300>
<input type=submit>
</div>
</form>

Ok, why won’t this open the url I type into the text box?

I even tried not overriding the submit method but making the input type be just a button whose “onClick” method was to call the “getURL()” function.

Ack! So friggin’ simple but I am totally lost.

Ok, THAT was weird… my body tag was empty when I typed it (just copied and pasted from my text editor, actually), and look at what the [**code] function put in.

Strange.

Try this:


parent.theBrowser.location.href = theURL;

Or, alternatively, using the index value for the target frame:


parent.frames[1].location.href = theURL;

BTW, this requires the “http://” on the front of the URL. You could make it a little more robust by checking the input to see if it had the “http://” and prepending it if it is missing.

Nope, it still tries to pass it on as a file on my computer.

Here is the address that it tries to resolve:


res://C:\WINDOWS\SYSTEM\SHDOCLC.DLL/dnserror.htm#file://D:\dsstuff\htmldocs\[object]

I’m stumped BIG time.

I neglected to include that I’d added the “value” property on the end of the form variable read when I tested the code:


    function getURL() {
        var theURL = document.fetcher.URL.value;
        parent.frames[1].location.href = theURL;
    }

This code works in MSIE 5.5 and NN 4.73.

I knew I was stupid… all it was was the “.value”

sigh thanks thanks

Actually, I think this is a perfect time for me to learn regular expressions to check for a malformed URL. Wish me luck. :Þ