473,324 Members | 2,254 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,324 software developers and data experts.

Need to Simulate onClick From Select Menu

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
1 9307
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Draken | last post by:
I have a function in the head section of a html and call it from a radio button with onClick="menu();" but IE tells me that the object doesnt support this method or property. What is the problem...
8
by: George Hester | last post by:
In a page I have when the user left-clicks the page a Input box for a form gets the focus. But if the user right-clicks the page the Input box is not getting the focus. I'd like the Input box to...
2
by: Jackson Yap | last post by:
can someone kind enough to help me look at the attached html and js file? Why is it that the javascript menu could not work at www.apchosting.net but could work at...
18
by: Ed Jay | last post by:
<disclaimer>js newbie</disclaimer> My page has a form comprised of several radio buttons. I want to poll the buttons to determine which button was selected and convert its value to a string. I...
6
by: daveyand | last post by:
Hey Guys, I've stumped. I created a function that does various things to select boxes. Namely Get All selected indexes, populate array with these values
1
by: melton9 | last post by:
I've been searching around and haven't really found anything. I've but an IE browser on my form and would like to simulate clicking the provided refresh button on a one minute interval. I can't...
6
by: dragze | last post by:
Hi, right i have a menu box wich allows the user to change what stylesheet the website uses. Now this all works just the way it shud in FF, but not in safari or IE, when u select ur option from the...
20
by: Charles | last post by:
Hello, On my web site, I have a <selectdrop-down menu that allows to show/ hide divs: http://tchernobyl.dreamhosters.com - The problem is that it doesn't work in IE7 (only tested in Opera and...
1
by: bhosalevivek | last post by:
I did this code from Dynamic Drive DHTML. it's working properly, but now I need submenu for "Submenu 1.2", means when I take mouse on "Submenu 1.2" I need to display "Submenu 1.2.1". I try to do...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.