Using onstop


Using onstop

The onstop event occurs when the user clicks the Internet Explorer's Stop button (which usually makes the browser stop loading a document). You can connect a function to this event like this: document.onstop = handlerFunction , like this: <SCRIPT FOR="document" EVENT="onstop"> ,or using the ONSTOP event attribute in the <BODY> element, which will pass the event on to the document.

Here's an example using this eventin this case, I'll modify Listing 08-08.html, which displayed a clock that updates every second, to stop when the user clicks the Stop button:

(Listing 09-11.html on the web site)
 <HTML>      <HEAD>          <TITLE>              Using the onstop Method          </TITLE>          <SCRIPT LANGUAGE="JavaScript">              <!--             document.onstop=stopCounting              var intervalID = ""              intervalID = window.setInterval("showTime()", 1000)              function showTime()              {                  var d = new Date()                  document.form1.text1.value = d.toLocaleTimeString()              }              function stopCounting()              {                  window.clearInterval(intervalID)              }              // -->          </SCRIPT>      </HEAD>      <BODY>          <H1>Using the onstop Method</H1>          <FORM NAME="form1">              <INPUT TYPE="TEXT" NAME="text1">          </FORM>      </BODY>  </HTML> 

And that's all it takesnow this clock works as before, but when you click the Stop button, the clock will stop.

That concludes our look at the document object's properties, methods , and events in this chapternow it's time to turn to the <BODY> element.



Inside Javascript
Inside JavaScript
ISBN: 0735712859
EAN: 2147483647
Year: 2005
Pages: 492
Authors: Steve Holzner

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net