Home Articles FAQs XREF Games Software Instant Books About Feedback Search Site-Map
irt.org logo

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?

irt.org | Knowledge Base | JavaScript | Frame | Q532 [ previous next ]

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?

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>

Provide feedback ...
AddThis Social Bookmark Button

Provide feedback ... AddThis Social Bookmark Button


Last Updated: 30th March 2008. Maintained by: Martin Webb and Michel Plungjan
irt.org liability, trademark, document use, privacy statement and software licensing rules apply.
Copyright © 1996-2008 irt.org, All Rights Reserved.