Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Behaviour of window.focus() with IE8

Posted on 2009-07-09
2
Medium Priority
?
1,952 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 75

Accepted Solution

by:
Michel Plungjan earned 2000 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

Preface This is the third article about the EE Collaborative Login Project. A Better Website Login System (http://www.experts-exchange.com/A_2902.html) introduces the Login System and shows how to implement a login page. The EE Collaborative Logi…
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. …
The viewer will learn how to count occurrences of each item in an array.
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).

604 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