Forum Moderators: open

Message Too Old, No Replies

IE focus() anchor without error?

Not even onload!

         

JAB Creations

3:59 am on Oct 23, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



This works like many other attempts though spawns an error in IE 5.0, 5.5, 6.0, and 7.0...
document.getElementById('an_element').focus();

How can we give an anchor element focus without IE crying about errors?

- John

XtendScott

5:27 pm on Oct 23, 2007 (gmt 0)

10+ Year Member




window.onload = myFunction

function myFunction()
{
document.getElementById('an_element').focus();
}

with HTML
<a tabindex="0" id="an_element" href="page.htm" onfocus="alert('focus');">Page</a>

Works for me in IE 6

[edited by: XtendScott at 5:28 pm (utc) on Oct. 23, 2007]

JAB Creations

7:28 pm on Oct 23, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Posting in a rush...

It's an error with jQuery in IE6... dragging the layer via it's h2 element.

- John

$(document).ready(function() {$('#prompts').Draggable({containment : 'parent', ghosting: true, opacity: 0.5, fx: 300, handle: '#promptsspan', zIndex: 1000,});});