0

I want to open a popup window which should be on top when ever a link from its parent page is clicked. For example when I click on a link (on a parent page) a popup window open and when I click on another link of parent page the previous popup window become on top of that parent page (and all other open browser's windows)

I have tried the following codes in that popup window HTML but with no luck.

<body onLoad="window.focus();">

and

<body onLoad="self.focus();">

and

<body onBlur="self.focus();">

Neither of these works. I am using Chrome browser if that helps. Please help!

6
  • 4
    You cannot reliably force a client to raise a window to the top. Some will, some won't. You really can't even guarantee that a new window won't simply be a new tab.
    – Pointy
    Sep 29, 2014 at 13:50
  • FYI - it should be onload and onblur developer.mozilla.org/en-US/docs/Web/HTML/Element/body
    – wirey00
    Sep 29, 2014 at 13:51
  • @ᾠῗᵲᄐᶌ: Tried changing the code as you suggested, it didn't worked either. Pointy: How can I make it so that it should be on focus when a link is clicked from its parent page? Sep 29, 2014 at 13:55
  • @The One and Only ChemistryBlob: Yes tried that too, it didn't worked Sep 29, 2014 at 13:57
  • 1
    I believe I have dabbled with this on my site and at the least you need to refer to the popup window name and focus it: window.open('', 'myPopup', '').focus(); Sep 29, 2014 at 13:57

1 Answer 1

8

Try adding .focus() at the end of your popup window javascript (just before ;)

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.