SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Member
    Join Date
    Dec 2002
    Location
    Redondo Beach, California, USA
    Posts
    2
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Browser Test for Active JS and New Window

    Greetings,

    I would like to display "information" type pages (Help Info, etc...) in a new "Popup Window" on my site when visitors have JavaScript active and allow New Windows set in their Browser. If they don't permit either of these, I would display the information in just a standard Web Page on my Site.

    Does anyone know what I can do to test if JavaScript is active in a Browser and then if New Windows are allowed, prior to presenting an information "Popup Window"?

    Any assistance would be most appreciated.

    Cheers,


    Wayne

  2. #2
    SitePoint Evangelist SpaceFrog's Avatar
    Join Date
    Jan 2005
    Location
    Outerspace
    Posts
    511
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Code:
    // Window identifier
    var idX=null;
    
    // Function called on body onload
    function send() {
      idX = window.open("", "XWin");
    
      // valids new window
      idX.document.open();
    
      //  >250ms timer for window to open
      // and determin if window still exists
      setTimeout("send2();", 350);
    }
     
    // tests if window is still open
    // if so you can load wanted page (in example : letsGo.asp)
    // if not alert message
    function send2() {
       if (idX==null || idX.closed) {
         alert("something is wrong here!!!");
       } else {
         document.confirmOffre.action="./letsGo.asp";
         // Same name as for window.open.open()
         document.confirmOffre.target="XWin";
        document.confirmOffre.submit();
      }
    }


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
  •