Explanation
I just thought, I'll do this to show you how very versatile Dynamic HTML is. Okay, before anyone of you tell me this, let me admit (and once again remind you) that it would only work on version 4 or higher browsers. So, yes, that's a limitation! On the otherhand, since both the major Browsers are available for Free download, I can't see why some people refuse to upgrade to the latest versions? It is possible that they aren't sure how to set the New Browser software. Let me clarify that the executable files will upgrade to the newer version automatically once you have downloaded them. So do visit Netscape Home Page OR Microsoft Home Page to download the latest version of Netscape Communicator OR Internet Explorer, whichever you prefer.
Getting back to the Script, there are two main advantages:
- One - that you can do away with larger Animated .GIF files. (A decent animated bar would not be less than 3~4 KBs)
- If you are "borrowing" an image, then you are limited by the width of the bar that the creator of the GIF file had set it to. As more & more people are setting their Web Pages to higher width, a standard (max) 600 width bar, at times, looks rather odd on the page. This script, lets you choose the length of the animation using a reasonably small graphic that you may have collected from one of the Freebie sites.
To achieve what I set out to do, I first created a small Graphic - "The Good Witch with her proverbial Broom!". Just about 1 KB in weight and 125 x 35 pixels in size. Having done that, one has to then decide, where exactly should this be placed. I have put this at 340 pixels from top. Let's now go into the details.
- This page is within a table - width of which has been set to 610 pixels. (You can set yours to whatever width you want - that will not affect the script). What I did want, was for the Image to scroll over the full length - that is, end at 10 position on left (that the position from where the TABLE starts - leaving 10 pixels left margin by default), starting at 610 at right.
- Accordingly, in the Script, I set the left margin to 10 while the starting point was set at 475 through this statement:
if (parseInt(anim.left) < 10)
{ anim.left =475 }
- You may wonder WHY 475? Well, if I place the right edge of a 125 pixels wide GIF Image, the left edge of it will be at 610 (10 + 475 + 125), correct? So, it then covers the full width of the table.
- Again, you can decide what should be the scrolling length - the left position can even be a negative value. For instance, in this script if you change the left position to "-125", the Graphic will scroll to that position - hiding it completely from view for a moment.
- Likewise, the right position can also changed.
- Then, I have set the STEP of the scroll to 5. Choice is yours!
- To ensure that any text below this DIVIDER does not overwrite the divider itself, I have inserted a clear image here, which gets written only if the viewer is using a Fourth Generation or higher browser. This is how that is done:
<script language="javascript">
<!-- use this as the spacer
if(ns4||ie4){
document.writeln('<img src="witchspacer.gif" width=20 height=50 border=0>')
}
//-->
</script>
You can, however, insert this space by using multiple <BR> tags instead.
- Finally, remember to specify the Font Size & Font Family within the Style Sheets as I have done at "#explain". This is to ensure none of you visitor can alter the body page size - thus ensuring the text height above the Divider will remain firm.
By the way, I have named this "document" - broom.
Just a point to remember - On older browsers, the image will NOT animate - it will appear as a still graphic at a position as per the flow of the document.
The script
| Paste this section within the HEAD tags
<script language="javascript">
<!-- hide from old browsers
// Written & created by Shivaji Basu
// Copyright www.shivbasu.com
// Use this script at your own risk
// To use his script, you MUST leave this disclaimer & credit as it is.
ns4 = (document.layers)? true:false
ie4 = (document.all)? true:false
function init() {
if(ns4){
anim = document.broom;
}
else
if (ie4) {
anim = broom.style;
}
animateit()
}
function animateit() {
anim.left = parseInt(anim.left)-5;
if (parseInt(anim.left) <10)
{ anim.left =475 }
setTimeout("animateit()",50);
}
//-->
</script>
<!--This is what ensures that the font sizes remain firm - All text in the Body should be wrapped within this DIV tag -->
<style type="text/css">
<!--
#explain{text-align:justify;font-size:14px;font-family:helvetica;}
-->
</style>
Paste this part within the OPENING Body tag for Auto execute
<BODY onload="init()" background="" bgcolor="" .....>
// Fill in the Background Image URL, BG color etc as normal
Paste this in the main Body
<script language="javascript">
<!-- use this as the spacer
if(ns4||ie4){
document.writeln('<img src="witchspacer.gif" width=20 height=50 border=0>')
}
//-->
</script>
<div id="broom" style="position:absolute; top:310; left:10; width:125">
<IMG SRC="goodwitch.gif" WIDTH="125" HEIGHT="35" border=0></div>
|
Copyright DBS © 1998-2003. All Rights Reserved |
|