showModalDialog in IE sets focus automatically. Why?

611 views Asked by At

In IE 9 (I'm assuming other IEs as well): using window.showModalDialog causes IE to set focus to the first focusable element in a page. This code demonstrates the issue:

<a href='javascript:window.showModalDialog("http://stackoverflow.com/")'>This sets focus to the search box</a>

<br>

<a href='javascript:window.open("http://stackoverflow.com/")'>This doesn't</a>

Fiddle: http://jsfiddle.net/Vz4Yb/

This is pretty annoying because I have some pages that have an image inside an A tag as the first element, and it puts an ugly focus rectangle around the image when the page loads. No other browser seems to be doing this. Has anyone else noticed this before, and is there a way to tell IE to NOT do this?

0

There are 0 answers