• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 464
  • Last Modified:

cross browser compatible Popup window with simple javascript

Hi - I'm trying to get a simple extra browser window to open when I click a  button.  It's a demo of how a Help file will open in another window when the user clicks the "?" button.

I found the script attached and was happy with all the options it provided but I'm getting really sketchy results.

IE6 "blinks" when the new window opens. The window calling the function kind of goes blank for a second.

Firefox wants to download the new content or open it with IE.

Is this a simple thing to remedy?

Thanks in advance for your experience.

function openHelpWin()
window.open("_help/HelpFile.mht","_blank","toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=yes, resizable=no, copyhistory=no, width=480, height=270");
<!-- and then I call it with this -->
<input type="image"  src="_images/square_Help_btn_off.jpg"  alt="HELP" onclick="openHelpWin()" />

Open in new window

  • 2
1 Solution
dzash2000Author Commented:
Hi -
Here's more information.  

I found out what was happening when IE6 blinks out as I described before.  The source page (the page with the Help button calling the function) is reloading!  

This make the whole situation even worse.  I need to keep the source page from reloading.  That's imperative!

I hope I explained this well enough.

Not sure about that IE6 reloading - I'll fire up the laptop tomorrow and try your example.

Meanwhile: I have found the spaces in the features list are a Very Bad Thing. Sometimes they will be applied, sometimes not, so I always remove spaces. Thus this:

"toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=yes, resizable=no, copyhistory=no, width=480, height=270"

becomes this:

The image input acts like a submit button (but the coordinates of the image that were activated are sent back to the server in addition to the rest of the form data).

So when you click on the image the onclick event is fired and a new window opened then the page reloads because the form has been submitted.

To prevent submission add a "return false;" just after your function call (see snippet below) in the onclick event.

Firefox doesn't support by default MHT files, so the default behavior is asking you to save it, or open it with the default associated application (normally IE). You can solve this problem locally by installing one of the several plugins available to enable MHT support.

<input type="image"  src="_images/square_Help_btn_off.jpg"  alt="HELP" onclick="openHelpWin(); return false;">

Open in new window

dzash2000Author Commented:
bugada - thanks.  "return false" was the magic word(s) that did the trick. It works great now.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now