Home Articles FAQs XREF Games Software Instant Books BBS About FOLDOC RFCs Feedback Sitemap
irt.Org
#

Q532 How can I make sure that options selected from a drop down list open up the selection in the current frame if they are local files and opened up in the top frame if they are remote files?

You are here: irt.org | FAQ | JavaScript | Frame | Q532 [ previous next ]

Use relative references for the local files and absolute references for the remote files:

<script language="JavaScript1.2"><!--
function surfto(selectlist) {
    var url = selectlist.options[selectlist.selectedIndex].value
    if (url != '') {
        if (url.indexOf('http://') > -1)
            top.location.href = url;
        else
            location.href = url;
    }
}
//--></script>

<form>
<select name="myOption" onChange="surfto(this)">
<option value="">Choose One:
<option value="local.htm">Local Page
<option value="http://www.somewhere.com/">Remote Page
</select>

©2018 Martin Webb