SitePoint Sponsor

User Tag List

Results 1 to 6 of 6
  1. #1
    SitePoint Member
    Join Date
    Sep 2005
    Posts
    18
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Angry Open new window problem

    Hi all,

    I am having quite the frustrating problem here. All I want to do is popup a small window when my main page loads.

    Here is what I have for the body tag

    <body onload="popupNTN()" bgcolor="#ffffff" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">

    The popupNTN is defined as:

    <script LANGUAGE="JavaScript" TYPE="text/javascript">
    <!--
    function popupNTN() {
    window.open("http://www.mydomain.com/PopUp.html")
    return true
    }
    //-->
    </script>

    This is not working though! I don't understand. Firefox and IE are not reporting any type of javascript error. What am I doing wrong??

    Thanks for the help!

  2. #2
    Programming Team silver trophybronze trophy
    Mittineague's Avatar
    Join Date
    Jul 2005
    Location
    West Springfield, Massachusetts
    Posts
    17,226
    Mentioned
    194 Post(s)
    Tagged
    2 Thread(s)

    window.open

    window.open takes 3 arguments. Maybe you need them all? eg.
    HTML Code:
    window.open("http://www.mydomain.com/PopUp.html","","")

  3. #3
    SitePoint Member
    Join Date
    Jun 2006
    Location
    Los Angeles
    Posts
    23
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    It seems to work for me. Are you sure you don't have your popup blocker on?

  4. #4
    SitePoint Member
    Join Date
    Jun 2006
    Location
    Los Angeles
    Posts
    23
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Here is the code that I used:

    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" xml:lang="en" lang="en">
    <head>
    	<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    
    	<title>untitled</title>
    	<script LANGUAGE="JavaScript" TYPE="text/javascript">
    	<!--
    	function popupNTN() {
    	window.open("http://www.google.com");
    	return true
    	}
    	//-->
    	</script>
    </head>
    
    <body onload="popupNTN()" bgcolor="#ffffff" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">
    
    test
    </body>
    </html>

  5. #5
    Programming Since 1978 silver trophybronze trophy felgall's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, NSW, Australia
    Posts
    16,861
    Mentioned
    25 Post(s)
    Tagged
    1 Thread(s)
    Quote Originally Posted by Mittineague
    window.open takes 3 arguments. Maybe you need them all? eg.
    HTML Code:
    window.open("http://www.mydomain.com/PopUp.html","","")
    Window.open can take up to FOUR arguments (not just three) but they are all optional so you can just specify window.open() by itself.


    If a popup is not appearing then it is probably being blocked.
    Stephen J Chapman

    javascriptexample.net, Book Reviews, follow me on Twitter
    HTML Help, CSS Help, JavaScript Help, PHP/mySQL Help, blog
    <input name="html5" type="text" required pattern="^$">

  6. #6
    SitePoint Member
    Join Date
    Apr 2006
    Posts
    18
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    It might be because of popup-blocker. It work very well in IE, firefox, and opera.
    Kirtan


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •