Forum Moderators: open

Message Too Old, No Replies

On Click issue with Buttons IE using Javascript

         

mmestrov

7:03 pm on Nov 22, 2006 (gmt 0)

10+ Year Member



Why is it in IE when I single click on a tool which calls a Javascript I have to click twice in order for the tool to work. In Fire Fox & Netscape it works fine on a single click. Is there a way around this.

<a onmouseover="javascript:overPic('zoomin')" onclick="javascript:setmapaction('zoomin')"onmouseout="javascript:outPic('zoomin')"><img title='Zoom In' name='zoomin' border=0 src='images/zoomin_2.gif'></a>

Thanks, M

Fotiman

7:44 pm on Nov 22, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Sounds like something wrong with the application. Try this in IE:


<script type="text/javascript">
function doSomething()
{
alert("Do it!");
}
</script>
<a href="#" onclick="doSomething();return false;">Click it</a>

You should find that you don't need to click more than once.

Also, get rid of all those "javascript:".

<a onmouseover="javascript:overPic('zoomin')" onclick="javascript:setmapaction('zoomin')" onmouseout="javascript:outPic('zoomin')">

Can be condensed to:

<a onmouseover="overPic('zoomin')" onclick="setmapaction('zoomin')" onmouseout="outPic('zoomin')">

[edited by: Fotiman at 7:44 pm (utc) on Nov. 22, 2006]

rocknbil

5:35 am on Nov 23, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Look in your setmapaction() function for a value that may not be defined until the first time you click it. So the first time it sets the value, the second it actually acts on it. It also helps to test in FireFox and use the Javascript control panel regularly - this may show up as an "[object or variable] not defined" error for the first click.