Need to Simulate onClick From Select Menu

S

Steve M.

Hello all.

I have a dropdown list:

<select name="select" class="mapMenu" onChange="JumpToIt(this)">
<option selected value="none">Select a Tool --</option>
<option value="javascript:eek:nCreatePrintable()">Print Map</option>
<option value="javascript:eek:nFindLatLong()">Find Lat/Long</option>
</select>

That calls a script:

<SCRIPT LANGUAGE="JavaScript">
<!--
function JumpToIt(list) {
var newPage = list.options[list.selectedIndex].value
if (newPage != "None") {
location.href=newPage
}
}
//-->
</SCRIPT>

Which in turn selects an option from the original dropdown.

Works fine except.....

The options in the select call scripts that open new browser windows,
and when this occurs popup blockers swing into action and block the new
window. When I originally had the javascript calls as plain links such
as [HREF="javascript:eek:nCreatePrintable()"] the popup was not blocked
since it was obvious that user was clicking the link. Now that I'm
trying to save much needed space by putting these links into a
dropdown, the popup blockers are not recognizing the user selection....
I guess. I was thinking the javascript could somehow simulate an
onClick to alleviate the problem. Any suggestions?

Thanks

Steve,
 
R

Randy Webb

Steve M. said the following on 5/19/2006 1:11 PM:
Hello all.

I have a dropdown list:

<select name="select" class="mapMenu" onChange="JumpToIt(this)">
<option selected value="none">Select a Tool --</option>
<option value="javascript:eek:nCreatePrintable()">Print Map</option>
<option value="javascript:eek:nFindLatLong()">Find Lat/Long</option>
</select>

That is one messed up way of creating a select list.
That calls a script:

<SCRIPT LANGUAGE="JavaScript">
<!--

function JumpToIt(list) {
var newPage = list.options[list.selectedIndex].value
if (newPage != "None") {
location.href=newPage
}
}
//-->
</SCRIPT>

Which in turn selects an option from the original dropdown.
Works fine except.....

Evidently it doesn't.
The options in the select call scripts that open new browser windows,
and when this occurs popup blockers swing into action and block the new
window. When I originally had the javascript calls as plain links such
as [HREF="javascript:eek:nCreatePrintable()"] the popup was not blocked
since it was obvious that user was clicking the link.

That is a bad way to create links as well.
Now that I'm trying to save much needed space by putting these links into a
dropdown, the popup blockers are not recognizing the user selection....
I guess.

Maybe, maybe not. Instead of a SELECT list of links, use one of the many
many "fly out menus" on the web. It is a dHTML effect mimicking what you
are trying to do and saves on that page space. There are even CSS only
menus out.
I was thinking the javascript could somehow simulate an
onClick to alleviate the problem. Any suggestions?

Yeah, think about it. If JS could simulate the click of an element, and
popup blockers wouldn't block it, what would stop the porn spammers from
doing something like this:

for (i=0;i<100;i++){
window.someElement.click();
}
Where clicking that element would open a random porn page?

It won't take long to realize part of why you can't do what you are
wanting to do.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,770
Messages
2,569,584
Members
45,075
Latest member
MakersCBDBloodSupport

Latest Threads

Top