Solved

Behaviour of window.focus() with IE8

Posted on 2009-07-09
2
1,946 Views
Last Modified: 2013-11-19

I am trying to simulate the functionality of modal dialog windows using javascript..

I would do this by invoking the window.focus method of the dialog window whenever the parent window gets focus.

This has worked fine with IE6 and with IE7 ; but with IE 8 - it works well on some workstations; however on other workstations all that happens is that the taskbar button for the dialog window flashes when window.focus() is invoked.. (the dialog window is not brought up to the front)


I open the dialog window like this:

dialogWin =window.open('aform.aspx','aaa', attr);

...

I handle the onfocus event of the opener window like this:

if (dialogWin != null && !dialogWin.closed)
{
            dialogWin.focus();
}


This has worked well with past versions of IE; however it does not work with IE 8 on some workstations (the button on the taskbar merely flashes)

Is there any other approach I can take?   I realize I can use showModalDialog; but this would involve rewriting a lot of code.



Thanks

0
Comment
Question by:atomic500
2 Comments
 
LVL 75

Accepted Solution

by:
Michel Plungjan earned 500 total points
ID: 24820840
Why would it involve a rewrite?

If you really want to, you can do

if (window.showModalDialog) window.open=new function(url,target,parms) {
  var ret = showModalDialog(url,window,parms.replace(',',';').replace('width','dialogWidth').replace('height','dialogHeight'); // add whatever you need
  return ret
}


so only where you need to manipulate the window afterwards do you need to change stuff and you can do a change of
opener.
to
if (window.dialogArguments) opener=window.dialogArguments

However a better choice is to use something like lightbox 2 or thickbox or greybox since it does not involve opening new windows which is blocked on many PCs
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

When it comes to write a Context Sensitive Help (an online help that is obtained from a specific point in state of software to provide help with that state) ,  first we need to make the file that contains all topics, which are given exclusive IDs. …
Building a website can seem like a daunting task to the uninitiated but it really only requires knowledge of two basic languages: HTML and CSS.
The viewer will receive an overview of the basics of CSS showing inline styles. In the head tags set up your style tags: (CODE) Reference the nav tag and set your properties.: (CODE) Set the reference for the UL element and styles for it to ensu…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)

749 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question