# I must be stupid-- JavaScript help

**URL:** https://boards.straightdope.com/t/i-must-be-stupid-javascript-help/84513
**Category:** Factual Questions
**Created:** [September 29, 2001, 8:12pm UTC](https://boards.straightdope.com/t/i-must-be-stupid-javascript-help/84513 "2001-09-29T20:12:58Z")
**Posts on this page:** 7
**Page:** 1

<div class="post-metadata">

### Author: ![erislover](https://avatars.discourse-cdn.com/v4/letter/e/71e660/32.png) [@erislover](https://boards.straightdope.com/u/erislover)
#### Post date: [September 29, 2001, 8:12pm UTC](https://boards.straightdope.com/t/i-must-be-stupid-javascript-help/84513/1 "2001-09-29T20:12:58Z")

</div>

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…

```auto

<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.

---

<div class="post-metadata">

### Author: ![erislover](https://avatars.discourse-cdn.com/v4/letter/e/71e660/32.png) [@erislover](https://boards.straightdope.com/u/erislover)
#### Post date: [September 29, 2001, 8:14pm UTC](https://boards.straightdope.com/t/i-must-be-stupid-javascript-help/84513/2 "2001-09-29T20:14:21Z")

</div>

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.

---

<div class="post-metadata">

### Author: ![micco](https://avatars.discourse-cdn.com/v4/letter/m/5f8ce5/32.png) [@micco](https://boards.straightdope.com/u/micco)
#### Post date: [September 29, 2001, 8:32pm UTC](https://boards.straightdope.com/t/i-must-be-stupid-javascript-help/84513/3 "2001-09-29T20:32:08Z")

</div>

Try this:

```auto

parent.theBrowser.location.href = theURL;

```

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

```auto

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.

---

<div class="post-metadata">

### Author: ![erislover](https://avatars.discourse-cdn.com/v4/letter/e/71e660/32.png) [@erislover](https://boards.straightdope.com/u/erislover)
#### Post date: [September 29, 2001, 8:42pm UTC](https://boards.straightdope.com/t/i-must-be-stupid-javascript-help/84513/4 "2001-09-29T20:42:59Z")

</div>

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

Here is the address that it tries to resolve:

```auto

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

```

I’m stumped BIG time.

---

<div class="post-metadata">

### Author: ![micco](https://avatars.discourse-cdn.com/v4/letter/m/5f8ce5/32.png) [@micco](https://boards.straightdope.com/u/micco)
#### Post date: [September 29, 2001, 9:01pm UTC](https://boards.straightdope.com/t/i-must-be-stupid-javascript-help/84513/5 "2001-09-29T21:01:29Z")

</div>

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

```auto

    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.

---

<div class="post-metadata">

### Author: ![erislover](https://avatars.discourse-cdn.com/v4/letter/e/71e660/32.png) [@erislover](https://boards.straightdope.com/u/erislover)
#### Post date: [September 29, 2001, 9:11pm UTC](https://boards.straightdope.com/t/i-must-be-stupid-javascript-help/84513/6 "2001-09-29T21:11:14Z")

</div>

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

_sigh_ thanks thanks

---

<div class="post-metadata">

### Author: ![erislover](https://avatars.discourse-cdn.com/v4/letter/e/71e660/32.png) [@erislover](https://boards.straightdope.com/u/erislover)
#### Post date: [September 30, 2001, 12:57am UTC](https://boards.straightdope.com/t/i-must-be-stupid-javascript-help/84513/7 "2001-09-30T00:57:46Z")

</div>

> [@](#):
>
> \*Originally posted by micco \*  
> 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.

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