DHTML : A gallery of scrolling images
Dr Benton
Implementing the effect for Internet Explorer
Once the HTML code is generated and stored in the variable, we can insert it into the current HTML page. For Internet Explorer,
we use the
<MARQUEE> tag:
var vitessevisio=4
if (document.all)
{
document.write('<marquee id="ieslider" scrollAmount=0 style="width:'+largvisio+'">'+visio_final+'</marquee>')
ieslider.scrollAmount=0
ieslider.scrollAmount=vitessevisio
ieslider.onmouseover=new Function("ieslider.scrollAmount=0")
ieslider.onmouseout=new Function("if (document.readyState=='complete') ieslider.scrollAmount=vitessevisio")
}
We define the
<MARQUEE> element by combining the tag, its identifier (
ieslider, which is essential for handling the tag later on) and our variable
visio_finale. The JavaScript
document.write function outputs the created tag onto the Web page.
The scrolling is in place and now we just need to implement the functions for stopping and resuming it. To stop the scrolling
of a
Marquee element, we have to change its
.scrollAmount property. By associating it with the
onmouseover event, we can stop the scrolling of our banner by assigning the value
0 to this property.
To resume the scrolling of the gallery at the speed given by
vitessevisio, we just have to again change the
.scrollAmount property of the
Marquee by assigning it the value of
vitessevisio. This assignment occurs when the
onmouseout event is fired, so that scrolling resumes when the mouse pointer is moved away from the gallery.
Rapid detection! To detect the visitor's browser properly, we should have created a function specially for this purpose. But, as you now know,
we just need to test whether
document.all evaluates to true, which means that the browser used is Internet Explorer. This is what we have done here!