Debt Consolidation - Watch Anime Online - Debt Consolidation - Business Gifts - Debt Consolidation

PDA

View Full Version : Problem with focus


adamjblakey
Jun 19th 2007, 5:04 am
Hi,

I have a function which hides and shows a div.

When i click the link to show the the div the page loads at the top. What i want to do is keep the focus on the link.

This is what i am using but does not seem to work?

function change(which) {
document.getElementById('div1').style.display = 'block';
document.getElementById('div1').focus();
}

Here is the link: <a href="#" onclick="change('div1');">Click here</a>

Any ideas why it is not working?

nico_swd
Jun 19th 2007, 5:42 am
<a href="#" onclick="change('div1'); return false;">Click here</a>


Just add a return false at the onclick attribute.

Or replace the # with javascript:;

<a href="javascript:;" onclick="change('div1');">Click here</a>


I think void(0); should work too...

adamjblakey
Jun 19th 2007, 5:52 am
Cheers nico your a star as usual ;)