# JavaScript question

**URL:** <https://boards.straightdope.com/t/javascript-question/243778>\
**Category:** Factual Questions\
**Created:** [May 6, 2004, 3:51am UTC](https://boards.straightdope.com/t/javascript-question/243778 "2004-05-06T03:51:05Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![LouisB](https://avatars.discourse-cdn.com/v4/letter/l/dfb087/32.png) [@LouisB](https://boards.straightdope.com/u/LouisB)\
**Post date:** [May 6, 2004, 3:51am UTC](https://boards.straightdope.com/t/javascript-question/243778/1 "2004-05-06T03:51:05Z")

</div>

I’m working on a webpage that will use a JavaScript drop down menu. If I select a valid value, the new webpage pops up with no problems. If I select a value for which no new page exists, I get the old familiar “Page Cannot Be Displayed” error. I would really like to have my own error page pop up, but I don’t know what to change in the JavaScript—maybe I can’t do it at all.

This part of the JavaScript is in the Head portion: \<script language=“JavaScript”\>  
function doMoveBrowser(form) {window.location.href = form.gomenu.options[getSelectedValue()].value; } function getSelectedValue() {return document.goform.gomenu.selectedIndex }\</script\>

The part that is in the Body is pretty long; but the first few lines are:\<script language=“JavaScript”\>function goBrowser(form) {document.location.href = form.gomenu.options[form.gomenu.selectedIndex].value;  
form.gomenu.selectedIndex=0;} \</script\>

```
                &lt;form name="form" method="post"&gt;
                  &lt;div align="center"&gt; 
                    &lt;select name="gomenu" size="1" onChange="goBrowser(this.form)"&gt;
                      &lt;option selected&gt;Select Part Number&lt;/option&gt;

```

Is this enough information for someone to answer my question? I believe this Script, or a very similar one, is in widespread use, for what that’s worth.

I would appreciate any inputs.

---

<div class="post-metadata">

**Author:** ![caphis](https://avatars.discourse-cdn.com/v4/letter/c/e19adc/32.png) [@caphis](https://boards.straightdope.com/u/caphis)\
**Post date:** [May 6, 2004, 4:13am UTC](https://boards.straightdope.com/t/javascript-question/243778/2 "2004-05-06T04:13:52Z")

</div>

Unless you tell the script which pages do not exist yet, then there’s no way to do this using JavaScript. You’ll need to use a custom 404 page, server side.

---

<div class="post-metadata">

**Author:** ![Shalmanese](https://avatars.discourse-cdn.com/v4/letter/s/45deac/32.png) [@Shalmanese](https://boards.straightdope.com/u/Shalmanese)\
**Post date:** [May 6, 2004, 6:09am UTC](https://boards.straightdope.com/t/javascript-question/243778/3 "2004-05-06T06:09:09Z")

</div>

are you re-directing to internal webpages only or any type of page?

---

<div class="post-metadata">

**Author:** ![LouisB](https://avatars.discourse-cdn.com/v4/letter/l/dfb087/32.png) [@LouisB](https://boards.straightdope.com/u/LouisB)\
**Post date:** [May 6, 2004, 11:21am UTC](https://boards.straightdope.com/t/javascript-question/243778/4 "2004-05-06T11:21:20Z")

</div>

> [@Shalmanese](#):
>
> are you re-directing to internal webpages only or any type of page?

At the moment, the pages are just being written. I hope to have them on a website eventually.
