Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. JavaScript
  4. body onunload

body onunload

Scheduled Pinned Locked Moved JavaScript
htmltoolstutorial
3 Posts 3 Posters 2 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • R Offline
    R Offline
    RabbitTrail
    wrote on last edited by
    #1

    I have been trying to get the method to work. I have seen and tried quite a few online examples including the example found on W3C (which is below). Even on their site, it doesn't work. I have tried to get the method to work by: Refresh the page, using back and forward buttons, and closing the window. Nothing happens in IE, Firefox or Chrome. I am at a loss as to why this doesn't work.

    <html>
    <head>
    <script>
    function myFunction()
    {
    alert("Thank you for visiting W3Schools!");
    }
    </script>
    </head>

    <body onunload="myFunction()">

    Welcome to my Home Page

    Close this window or press F5 to reload the page.

    </body>
    </html>

    V T 2 Replies Last reply
    0
    • R RabbitTrail

      I have been trying to get the method to work. I have seen and tried quite a few online examples including the example found on W3C (which is below). Even on their site, it doesn't work. I have tried to get the method to work by: Refresh the page, using back and forward buttons, and closing the window. Nothing happens in IE, Firefox or Chrome. I am at a loss as to why this doesn't work.

      <html>
      <head>
      <script>
      function myFunction()
      {
      alert("Thank you for visiting W3Schools!");
      }
      </script>
      </head>

      <body onunload="myFunction()">

      Welcome to my Home Page

      Close this window or press F5 to reload the page.

      </body>
      </html>

      V Offline
      V Offline
      vbmike
      wrote on last edited by
      #2

      I pasted your code as is into a file and it runs as it should. Perhaps you have a typing error in your actual code?

      vbmike

      1 Reply Last reply
      0
      • R RabbitTrail

        I have been trying to get the method to work. I have seen and tried quite a few online examples including the example found on W3C (which is below). Even on their site, it doesn't work. I have tried to get the method to work by: Refresh the page, using back and forward buttons, and closing the window. Nothing happens in IE, Firefox or Chrome. I am at a loss as to why this doesn't work.

        <html>
        <head>
        <script>
        function myFunction()
        {
        alert("Thank you for visiting W3Schools!");
        }
        </script>
        </head>

        <body onunload="myFunction()">

        Welcome to my Home Page

        Close this window or press F5 to reload the page.

        </body>
        </html>

        T Offline
        T Offline
        twseitex
        wrote on last edited by
        #3

        BODY object in Internet Explorer, see http://msdn.microsoft.com/en-us/library/ms535205(v=vs.85).aspx

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups