473,759 Members | 7,748 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Need to Simulate onClick From Select Menu

Hello all.

I have a dropdown list:

<select name="select" class="mapMenu" onChange="JumpT oIt(this)">
<option selected value="none">Se lect a Tool --</option>
<option value="javascri pt:onCreatePrin table()">Print Map</option>
<option value="javascri pt:onFindLatLon g()">Find Lat/Long</option>
</select>

That calls a script:

<SCRIPT LANGUAGE="JavaS cript">
<!--
function JumpToIt(list) {
var newPage = list.options[list.selectedIn dex].value
if (newPage != "None") {
location.href=n ewPage
}
}
//-->
</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="javascrip t:onCreatePrint able()"] 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 9358
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="JumpT oIt(this)">
<option selected value="none">Se lect a Tool --</option>
<option value="javascri pt:onCreatePrin table()">Print Map</option>
<option value="javascri pt:onFindLatLon g()">Find Lat/Long</option>
</select>
That is one messed up way of creating a select list.
That calls a script:

<SCRIPT LANGUAGE="JavaS cript">
<!--
<script type="text/javascript"> and ditch the <!-- //--> crap.
function JumpToIt(list) {
var newPage = list.options[list.selectedIn dex].value
if (newPage != "None") {
location.href=n ewPage
}
}
//-->
</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="javascrip t:onCreatePrint able()"] 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.someElem ent.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.javas cript 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
5739
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 with that? I have tried numerous ways around it but to no avail. <head> function menu() { for (i=0;i<=2;i++) { if (document.menuform.menu.checked=="1") { parent.main.location.href="document.menuform.menu.value + '.html'" }
8
2035
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 get the focus no matter where on the page the user clicks be it right-click or left-click. Right now there is no context menu when the user right-clicks. Do you think that's the problem? Any ideas how to get this right-click left-click Input box...
2
3893
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 http://home.pacific.net.sg/~jacksony ? (the drop down bar could not work at www.apchosting.net but can drop at home.pacific.net.sg. I suspect it is a server problem but was told it is not possible, therefore assuming it is a client script problem? the script works last time...
18
2268
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 then want to use the string on the same page. My script is: function checkRadio(field) { for(var i=0; i < field.length; i++) {
6
1754
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
1466
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 use navigate because the page has frames and only one frame does the refreshing. Surely theres a simple way to make the browser simulate the onclick of the particular button I'm wanting? Its javascript in frame 2. Can anyone help?
6
3057
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 box in safari or IE it does nothing. I have tested the same method but with hyperlinks rather than the menu box, this works with all three browsers, just wont wrk on the menu box for some reason. For all i know there could be a simple explanation to...
20
3172
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 Firefox). However, if I include the onclick event in an <atag, it works fine in IE (but not within <optiontags). Next to the drop-down menu, I put a "test" link which works fine in IE7. Do you know what may be the cause? Here's the snippet:
1
3058
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 this but it could't work. hope you understand my Language and My problem. please help me. Code is below. <html> <head>
0
10107
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9945
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9900
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
7324
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6599
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5214
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
3863
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
3442
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2733
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.