unwanted page reload

J

julian_m

After double-clicking the link the browser wants to reload the page,
even though there is not any link at all.
It doesn't happen if I change the "ondblclick" event to "onclick"

<a href="" ondblclick="show_div('the_div_3'); return false;">Div 3</a>
<div style="display: none;" id="the_div_1">This is div 1</div>

The javascript function is really a basic one...

<script type="text/javascript">
function show_div(div_id) {
document.getElementById(div_id).style.display = 'block';
}

</script>


Any hint?

regards- julian
 
N

Neredbojias

After double-clicking the link the browser wants to reload the page,
even though there is not any link at all.
It doesn't happen if I change the "ondblclick" event to "onclick"

<a href="" ondblclick="show_div('the_div_3'); return false;">Div 3</a>
<div style="display: none;" id="the_div_1">This is div 1</div>

The javascript function is really a basic one...

<script type="text/javascript">
function show_div(div_id) {
document.getElementById(div_id).style.display = 'block';
}

</script>

It's 'cause you have an empty href.

Do:

<a href="javascript:void(0)" ondblclick="show_div('the_div_3'); return
false;">
 
J

julian_m

Neredbojias said:
It's 'cause you have an empty href.

Do:

<a href="javascript:void(0)" ondblclick="show_div('the_div_3'); return
false;">
Great, thanks.

It's strange what happens with (click != dblclick) though

regards - julian
 
N

Neredbojias

To further the education of mankind, "julian_m"
Great, thanks.

It's strange what happens with (click != dblclick) though

The href picks up the click before the double-click, and when empty reacts
in browser-specific ways.
 

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

Forum statistics

Threads
473,768
Messages
2,569,575
Members
45,053
Latest member
billing-software

Latest Threads

Top