pop-up menus: followup

Christopher Handy charta at inetdirect.net
Thu Jun 25 00:11:35 EDT 1998


On 6/24/98, Kevin Justie wrote:

|>In experimenting with the methods used in the above two pages, plus a
|>couple of others, I was surprised to find that every one of them failed to
|>work in at leat one of the browser versions I was testing against (v.4 of
|>Explorer and Netscape in both Win95 and Mac; v. 3 of Explorer and Netscape
|>on Mac), and it wasn't always the older browser versions that didn't work
|>(the two methods listed above worked most consistently).  Have others found
|>this to be the case with Javascript?

I've recently been working on some pages for a local library and planned to
use one such menu navigator on the homepage. But somewhere along the line I
noticed that the Mac LC IIIs that are still widely used by the staff here,
running Navigator 2.02 and system 7.1 (I think), generally won't execute
the jump. I've rewritten my script in many different ways, but nothing
seems to work consistently on these machines. But I haven't noticed much
problem with NN or IE 3.x - 4.x. Or even with 2.02 running on a PowerMac.

Curiously, what I found worked as well as anything across platforms and
browsers was this single line of code placed in the <select> tag of the
pop-up menu form:

onchange="window.open(this.options[this.selectedIndex].value,'_top')"

If nothing else, it has the virtue of simplicity.

|>
|>So now, with a pop-up that works in the browsers we use, I've run into a
|>new problem.  Explorer 4.01 on the Mac and Explorer 4 on Win95 leave the
|>pop-up showing the previously selected menu item, even when the user
|>returns to the page containing the pop-up at a later time, making it
|>impossible for the user to select that item again (because there's no Go
|>button) without first selecting something else from the pop-up.  (Netscape
|>4, on Mac and Win95, works correctly, returning the pop-up to its default
|>item each time the page is displayed.)  Is there a Javascript method to
|>force a pop-up back to its default item after the user makes a selection
|>and jumps to another page?
|>

I'm not positive I understand the scenario you're describing, but you might
try including something like this in the <body> tag of your page (assuming
the first option in the list is the default):

<body onLoad="document.yourFormName.yourSelectName.options[0].selected=true">

I've never used this before, but testing it a couple of times just now it
seems to accomplish what I think you're after: When the user hits the
"back" button after performing a jump from the pop-up menu the option
specified above is (re)selected.

Of course you can also just include a redundant Go button, even though it
might be somewhat confusing to your users.

Chris
charta at inetdirect.net




More information about the Web4lib mailing list