By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,934 Members | 1,527 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,934 IT Pros & Developers. It's quick & easy.

Need to Simulate onClick From Select Menu

P: n/a
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:onCreatePrintable()">Print Map</option>
<option value="javascript:onFindLatLong()">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:onCreatePrintable()"] 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,

May 19 '06 #1
Share this Question
Share on Google+
1 Reply


P: n/a
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:onCreatePrintable()">Print Map</option>
<option value="javascript:onFindLatLong()">Find Lat/Long</option>
</select>
That is one messed up way of creating a select list.
That calls a script:

<SCRIPT LANGUAGE="JavaScript">
<!--
<script type="text/javascript"> and ditch the <!-- //--> crap.
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:onCreatePrintable()"] 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.
<URL: http://jibbering.com/faq/#FAQ4_24 >
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.

--
Randy
comp.lang.javascript FAQ - http://jibbering.com/faq & newsgroup weekly
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
May 19 '06 #2

This discussion thread is closed

Replies have been disabled for this discussion.