Web Analytics Made Easy -
StatCounter on unload function - CodingForum


No announcement yet.

on unload function

  • Filter
  • Time
  • Show
Clear All
new posts

  • on unload function

    I have a (quasi) legitimate reason to use the "on unload function," and now can't find where I was reading about it...

    does anyone know where to locate script for it?
    How come this stuff seems so simple when you guys do it? It takes me three days to figure how to ask my questions half-way intelligently!

  • #2
    Hi Judy, could give us an idea of what you want to happen with the onunload event handler. It makes a difference what script is used and could also need to include special syntax for cross browser compatibility.

    Example: If you just want to use the built-in alert box function for Netscape and Explorer to say "Thank you for visiting Regardless Shorthairs" then this anywhere in the body will do it.
    <BODY onUnload="alert('Thank you for visiting Regardless Shorthairs')">
    Even this doesn't work for other browsers.

    Edit: for sp.
    Last edited by newmate; Jun 22, 2002, 09:58 PM.
    Editor; FrontPage 2002 (included in Office XP). Personal Operating System; Windows XP and ME. Browsers; Latest versions, NN, IE and Opera. Server running; RedHat Linux 7.2


    • #3
      window.onunload = fuction() {

      Quick example of how to use it.


      • #4
        I may have a perverted sense of humor,

        but I found a script:


        that I think is really neat. When you click on a button, a page comes up that looks like what you see when you're downloading a program (sort of anyway). It says:

        "Now downloading virus"

        and looks as though something is actually downloading.

        I'd like to use it, but I can picture people madly trying to close the window, and leaving my site.

        So I want to use "on unload" to take them to a page explaining that it was a joke, with a history (-2) to take them back to the page they came from.

        An "on unload" pop-up would be nice, but I don't think I've ever seen one...
        Last edited by Judy; Jun 22, 2002, 10:58 PM.
        How come this stuff seems so simple when you guys do it? It takes me three days to figure how to ask my questions half-way intelligently!


        • #5
          Re: I may have a perverted sense of humor,

          Good heavens, no. Certainly not. Who could posibly have thought that?

          All the code given in this post has been tested and is intended to address the question asked.
          Unless stated otherwise it is not just a demonstration.


          • #6
            Dynamicdrive Unload popup


            Fair well window launcher script
            By JavaScript Kit (http://javascriptkit.com)
            Over 200+ free scripts here!

            function openpopup(){
            //configure "seeyou.htm and the window dimensions as desired

            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 (get_cookie('popped')==''){