Internet Explorer 5.0 Preview, Part I: Behavior Emulation with IE 4.0x - Doc JavaScript | WebReference

Internet Explorer 5.0 Preview, Part I: Behavior Emulation with IE 4.0x - Doc JavaScript


Behavior Emulation with IE 4.0x

In principle, Behavior functionality can be emulated with Internet Explorer 4.0x. In our example, a blinking image can be created using IE 4.0x's DHTML objects. Images can be moved and made invisible by manipulating their object's properties, such as visibility, left, and top attributes. Here is the full script:


<HTML>
<HEAD>
<TITLE> Soccer: World Cup is Over </TITLE>
</HEAD>
<BODY ONLOAD="soccerOnload()">
<DIV ID="soccer" STYLE="position:absolute; left:200; top:250"> -->
  <IMG SRC="bigsoccer.gif"></DIV>
<SCRIPT LANGUAGE="JavaScript">
var msecs = 2000;
var counter = 0;
function soccerOnload() {
  setTimeout("blink()", msecs);
}
function blink() {
  soccer.style.visibility =  -->
    (soccer.style.visibility == "hidden") ? "visible" : "hidden";
  counter +=1;
  if (counter == 10) {
    alert("Fifth Blink Point");
    counter = 0;
  }
  setTimeout("blink()", msecs);
}
</SCRIPT>
</BODY>
</HTML>

Notice we have added a small feature to our blinking soccer ball: an alert box that pops up every five blinks. We picked a simple event so it will be easier to explain later in this column how to implement an event with Behaviors.

https://www.internet.com


Created: July 19, 1998
Revised: July 19, 1998

URL: https://www.webreference.com/js/column22/emulate.html