How to Use Java Script & Scroll Image
- 1). Log in to your Web server. Open the HTML document in which you want to insert the JavaScript to scroll an image.
- 2). Click inside the <body> tag and insert this code:
<SCRIPT LANGUAGE="JavaScript">
<!-- Begin
window.onerror = null;
var bName = navigator.appName;
var bVer = parseInt(navigator.appVersion);
var IE9 = (bName == "Microsoft Internet Explorer" && bVer >= 9);
var IE6 = (bName == "Microsoft Internet Explorer" && bVer < 6);
var img_path="http://website.com.image.jpg";
var time_length =50; //Scroll delay in milliseconds
var begin_pos = 265; //Start position of scroll hint
var i=begin_pos;
var j=i;
var scroll_length = 350; //The scroll length
var original_time=time_length;
if (IE9) {
if (navigator.appName == "Internet Explorer") {
layerStyleRef="layer.";
layerRef="document.layers";
styleSwitch="";
}else{
layerStyleRef="layer.style.";
layerRef="document.all";
styleSwitch=".style";
}
}
//SCROLL RIGHT
function scroll_right(layerName)
{
if (IE9)
{
if(i<(begin_pos+scroll_length))
{
eval(layerRef+'["'+layerName+'"]'+
styleSwitch+'.visibility="visible"');
eval(layerRef+'["'+layerName+'"]'+ styleSwitch+'.left="'+(i)+'"');
i++;
j++;
}
if(i==j)
{
setTimeout("scroll_right('"+layerName+"')",time_length);
}
}
}
//SCROLL LEFT
function scroll_left(layerName)
{
if (IE9)
{
if(i>(begin_pos-scroll_length))
{
eval(layerRef+'["'+layerName+'"]'+
styleSwitch+'.visibility="visible"');
eval(layerRef+'["'+layerName+'"]'+ styleSwitch+'.left="'+(i)+'"');
i--;
j--;
}
if(i==j)
{
setTimeout("scroll_left('"+layerName+"')",time_length);
}
}
}
function scroll_out()
{
time_length=10000000000000;
}
function reset()
{
time_length=original_time;
}
document.write('<div style="position:relative; left:' + begin_pos + '"><img src="http://website.com.image.jpg"></b></div><center><a onmouseover="javascript:reset(); scroll_left('prem_hint');" onmouseout="javascript:scroll_out();"><b>
// End -->
</script> - 3). Change both instances of "http://website.com.image.jpg" to the actual URL of the image that you want to scroll. One instance is near the top of the code, while the other is near the bottom.
- 4). Publish the page.
Source...