Link to home
Create AccountLog in
Avatar of Tammu
Tammu

asked on

onload without using body tag popup window to open without blocked by popup blocker

Hello Experts,
I have this code i am using to display a popup image without using the body tag. the popup works but it DOES getting blocked by the popup blocker.

How I can do this without getting blocked by the popup blocker

here is my code

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>

<body>
<script language="javascript" type="text/javascript">
   window.onload = function open_new_window() 
{
new_window = open("","hoverwindow","width=290,height=320,left=180,top=180");

// open new document 
new_window.document.open();

// Text of the new document
new_window.document.write("<html><title>my site</title>");
new_window.document.write("<body bgcolor=\"#ffffff\">");
new_window.document.write("<div>");
new_window.document.write("<img src='http://www.mysite.com/images/must-see-deal.jpg'>");
new_window.document.write("</div>");
new_window.document.write("</body></html>");

// close the document
new_window.document.close(); 
}

// This is the function that will close the
// new window when the mouse is moved off the link
function close_window() 
{
new_window.close();
}

   
</script>
<div id="hp">this is test</div>

</body>

</html>

Open in new window

Avatar of Scottyworld
Scottyworld
Flag of New Zealand image

Thats the whole point of a popup blocker! If you could code round it, then everyone would!

You could try adding your site name to the allowed list in the popup blocker settings. In IE8 under Windows 7 this can be found at the follwoing registry key

HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\New Windows\Allow

Create a new Binary value, e.g.
*.experts-exchange.com
ASKER CERTIFIED SOLUTION
Avatar of Badotz
Badotz
Flag of United States of America image

Link to home
membership
Create an account to see this answer
Signing up is free. No credit card required.
Create Account
Avatar of Tammu
Tammu

ASKER

thanks
No worries - glad to help.