SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Zealot
    Join Date
    Jul 2002
    Location
    USA
    Posts
    132
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Javascript and Mozilla (1.5MacOSX)

    I have looked into creating a javascript that will do a PopUp "Exit Poll" when the client backs out or links forward from the domain. It is a moderated script I found through discussions on this forum.

    Now it works great in MSIE5.2.2 on MacOS10.1.5, but I'm finding I better also make sure it works in Mozilla if I have any chance of making it work on the PC side. When i try it in Mozilla, I get Javascript console saying "loadpopup() is not defined"

    I've found a couple javascripts that work in MSIE but not Mozilla..this is getting irritating to say the least.

    For MacOS10.3 owners using Safari, is the browser compatibility with javascript any better? I feel like I need to get away from MSIE5.2.2 altogether now. And no..I'm not buying a PC.

    Code:
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
    <html>
    <head>
    <title>Untitled Document</title>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    
    
    <script  language="JavaScript1.2" type="text/JavaScript1.2">
    
    /*
    Fair well window launcher script
    By JavaScript Kit (http://javascriptkit.com)
    note: script has been hacked from original
    */
    var exit = true; //### Set an exit variable to true ###
    
    function openpopup(){
    //configure "seeyou.htm and the window dimensions as desired
    window.open('http://domain.com/exit_poll.html','','toolbar=no,menubar=no,location=no,height=275,width=473');
    }
    
    function get_cookie(Name) {
      var search = Name + "="
      var returnvalue = "";
      if (document.cookie.length > 0) {
        offset = document.cookie.indexOf(search)
        if (offset != -1) { // if cookie exists
          offset += search.length
          // set index of beginning of value
          end = document.cookie.indexOf(";", offset);
          // set index of end of cookie value
          if (end == -1)
             end = document.cookie.length;
          returnvalue=unescape(document.cookie.substring(offset, end))
          }
       }
      return returnvalue;
    }
    
    function loadpopup(){
      if (exit){
        if (get_cookie('popped')=='' && get_cookie('expires')==''){
        openpopup()
        document.cookie ="popped=yes;expires=Tue, 31-Dec-2030 00:00:01 GMT;"
        }
      }
    }
    
    </script>
    
    
    </head>
    
    <body onUnload="javascript:loadpopup()">
    
    <p>source: http://javascriptkit.com/script/cut65.shtml</p>
    
    <p> <a href="nextpage.html" target="_self" onclick="javascript:exit=false;"
    >robinx.html</a></p>
    </body>
    </html>

  2. #2
    SitePoint Guru bronze trophy blufive's Avatar
    Join Date
    Mar 2002
    Location
    Manchester, UK
    Posts
    853
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    HTML Code:
    <script language="JavaScript1.2" type="text/JavaScript1.2">
    That's your problem right there. "text/JavaScript1.2" is not a valid mime-type. Change it to
    HTML Code:
    <script language="JavaScript1.2" type="text/javascript">
    and you're in much better shape.

    The next hurdle you'll have to get over is the fact that recent mozilla versions have a built-in popup blocker, which will merrily supress your popup because it's triggered via an onunload event handler.

  3. #3
    I'll take mine raw silver trophy MikeFoster's Avatar
    Join Date
    Dec 2002
    Location
    Alabama, USA
    Posts
    2,560
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Good eye, blufive

    One more thing, Boss Hoss...

    When assigning an event-handler to element attributes do not use the "javascript:" protocol prefix. This prefix is only for URLs, so only use it when you assign a string of javascript to an HREF attribute, or any place where you would use a URL.


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
  •