Solved

Behaviour of window.focus() with IE8

Posted on 2009-07-09
2
1,947 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 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

Don't Cry: How Liquid Web is Ensuring Security

WannaCry is just the start. Read how Liquid Web is protecting itself and its customers against new threats.

Question has a verified solution.

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

Is your Office 365 signature not working the way you want it to? Are signature updates taking up too much of your time? Let's run through the most common problems that an IT administrator can encounter when dealing with Office 365 email signatures.
Today, the web development industry is booming, and many people consider it to be their vocation. The question you may be asking yourself is – how do I become a web developer?
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
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)

688 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