468,103 Members | 1,328 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,103 developers. It's quick & easy.

debugging an old script

Hi, I have this pre-built JS routine that creates a text animation
special-effect. The routine was included inside a freeware HTML editor,
called AceHTML. The problem is that it seems to work only on IE and
IE-emulating browsers (such as Opera). According to what other people have
told me, the problem is because this script has an outdated browser
detection scheme, and that the procedure it uses for Netscape is no longer
valid in modern Netscapes/Mozillas, etc. Now, I'm no JS expert, I just
started doing HTML a couple of weeks ago to put up a personal page, so I
wasn't expecting to get involved in the bowels of JS programming and
debugging until much later when I'd become more advanced.

Specifically, the JSconsole error messages on Firefox shows that any lines
that start with "document.wds.document.write(...)" as being undefined.

If you want to see what this script looks like when it's working, then go to
this site, and look at the animated heading for this page (but use IE or a
compatible):

http://ca.geocities.com/bbbl67/mower4sale.html

I need to know how to make this thing work on any W3C-compliant browser. I
understand that even the IE portion of the script is outdated and irrelevant
to modern IE, but it still maintains backwards compatibility with it.

Yousuf Khan

I've pasted the script from the above mentioned page down below:

----------
<script language="JavaScript">

<!-- Begin

// Original: Charles Foster (wc*****@msn.com)

// Web Site: http://kylo.ml.org/flash
// This script and many more are available free online at

// The JavaScript Source!! http://javascript.internet.com

var speed = 100;

var cycledelay = 2000;

var maxsize = 28;
var x = 0;

var y = 0;

var themessage, size;

var esize = "</font>";
function initArray() {

this.length = initArray.arguments.length;

for (var i = 0; i < this.length; i++) {

this[i] = initArray.arguments[i];

}

}

var themessage2 = new initArray(

"SOLD!",

"Thanks for your interest"

);

if(navigator.appName == "Netscape")

document.write('<layer id="wds"></layer><br>');

if (navigator.appVersion.indexOf("MSIE") != -1)

document.write('<span id="wds"></span><br>');

function upwords(){

themessage = themessage2[y];

if (x < maxsize) {

x++;

setTimeout("upwords()",speed);

}

else setTimeout("downwords()",cycledelay);
if(navigator.appName == "Netscape") {

size = "<font point-size='"+x+"pt'>";

document.wds.document.write(size+"<center>"+themes sage+"</center>"+esize);

document.wds.document.close();

}

if (navigator.appVersion.indexOf("MSIE") != -1){

wds.innerHTML = "<center>"+themessage+"</center>";

wds.style.fontSize=x+'px';

}

}

function downwords(){

if (x > 1) {

x--;

setTimeout("downwords()",speed);

}

else {

setTimeout("upwords()",cycledelay);

y++;

if (y > themessage2.length - 1) y = 0;

}

if(navigator.appName == "Netscape") {

size = "<font point-size='"+x+"pt'>";

document.wds.document.write(size+"<center>"+themes sage+"</center>"+esize);

document.wds.document.close();

}

if (navigator.appVersion.indexOf("MSIE") != -1){

wds.innerHTML = "<center>"+themessage+"</center>";

wds.style.fontSize=x+'px';

}

}

setTimeout("upwords()",speed);

// End -->

</script>
--
Humans: contact me at ykhan at rogers dot com
Spambots: just reply to this email address ;-)

Jul 23 '05 #1
13 1361
On Thu, 26 Aug 2004 18:05:59 GMT, Yousuf Khan <bb****@ezrs.com> wrote:

[snip]
I need to know how to make this thing work on any W3C-compliant browser.
I understand that even the IE portion of the script is outdated and
irrelevant to modern IE, but it still maintains backwards compatibility
with it.


If I may be frank, abandon it. It would be much simpler to create an
animated GIF that displayed the same thing. Adding, "Sold! Thanks for your
interest.", to the alt attribute of such an image would also make your
page much more accessible. An animated GIF would also not cause the page
dimensions to constantly change.

To make the script, another example of the "high" quality of The
JavaScript Source's collection, workable in a wide range of browsers would
require it to be re-written from scratch. Considering the alternative, I
don't honestly think it's worth the effort.

[snip]

Sorry,
Mike

--
Michael Winter
Replace ".invalid" with ".uk" to reply by e-mail.
Jul 23 '05 #2
Michael Winter wrote:
If I may be frank, abandon it. It would be much simpler to create an
animated GIF that displayed the same thing. Adding, "Sold! Thanks for
your interest.", to the alt attribute of such an image would also
make your page much more accessible. An animated GIF would also not
cause the page dimensions to constantly change.
Actually, I kind of liked that effect. Made it look like a heartbeat or a
balloon.
To make the script, another example of the "high" quality of The
JavaScript Source's collection, workable in a wide range of browsers
would require it to be re-written from scratch. Considering the
alternative, I don't honestly think it's worth the effort.


I'll take it with advisement.

Yousuf Khan
Jul 23 '05 #3
On Fri, 27 Aug 2004 18:53:57 GMT, Yousuf Khan <bb****@ezrs.com> wrote:
Michael Winter wrote:
If I may be frank, abandon it. It would be much simpler to create an
animated GIF that displayed the same thing. Adding, "Sold! Thanks for
your interest.", to the alt attribute of such an image would also
make your page much more accessible. An animated GIF would also not
cause the page dimensions to constantly change.


Actually, I kind of liked that effect. Made it look like a heartbeat or a
balloon.


You missed the point. You can get the same effect, just with an animated
image rather than playing around with the font size. An image will be more
accessible (provided that you use the alt attribute), and it's guaranteed
to work almost in every graphical browser[1]. The same cannot be said for
that script, or any other like it.

[snip]

Mike
[1] "Almost" because some open-source graphical browsers do not implement
GIF loading properly because of the patent held on the GIF compression
algorithm.

--
Michael Winter
Replace ".invalid" with ".uk" to reply by e-mail.
Jul 23 '05 #4
"Yousuf Khan" <bb****@ezrs.com> wrote in message news:<bE*******************@news01.bloor.is.net.ca ble.rogers.com>...
Hi, I have this pre-built JS routine that creates a text animation
special-effect. The routine was included inside a freeware HTML editor,
called AceHTML. The problem is that it seems to work only on IE and
IE-emulating browsers (such as Opera). According to what other people have
told me, the problem is because this script has an outdated browser
detection scheme, and that the procedure it uses for Netscape is no longer
valid in modern Netscapes/Mozillas, etc. Now, I'm no JS expert, I just
started doing HTML a couple of weeks ago to put up a personal page, so I
wasn't expecting to get involved in the bowels of JS programming and
debugging until much later when I'd become more advanced.

Specifically, the JSconsole error messages on Firefox shows that any lines
that start with "document.wds.document.write(...)" as being undefined.

If you want to see what this script looks like when it's working, then go to
this site, and look at the animated heading for this page (but use IE or a
compatible):

http://ca.geocities.com/bbbl67/mower4sale.html

I need to know how to make this thing work on any W3C-compliant browser. I
understand that even the IE portion of the script is outdated and irrelevant
to modern IE, but it still maintains backwards compatibility with it.

Yousuf Khan

I've pasted the script from the above mentioned page down below:


That's a very old script and, apologies to the author, not a very good
visual effect.

Try this one: - seems to be hidden from Opera though.
----------------------------------------|
<script type="text/javascript">

if ((document.getElementById) &&
window.addEventListener || window.attachEvent){

var win = window.toString(); //No Opera!
if (win != "[object Object]" ){

(function(){

//Configure here.

var message = "your message here";
var col = new Array('#ff0000','#00aa00','#0000ff'); //add more.
var xyz = 26; //max grow size.
var spd = 40; //setTimeout speed.

//End.

var msg = message.split(" ");
var timer = null;
var clrPos = 0;
var msgPos = 0;
var jog = 1;
var currentStep = 10;
var step = 8;
var h,w,y,x,r,xy;
var d = document;
var pix = "px";
var domWw = (typeof window.innerWidth == "number");
var domSy = (typeof window.pageYOffset == "number");
var running = true;
var box,txt;
var ovrflw = (d.documentElement.style &&
typeof d.documentElement.style.MozOpacity == "string")
?"-moz-scrollbars-none":"hidden";
var idx = d.getElementsByTagName('div').length;

d.write("<div id='_box"+idx+"' style='position:absolute;top:0px;"
+"left:0px;height:10px;width:10px;text-align:center;"
+"overflow:"+ovrflw+"'>"

+"<div id='_txt"+idx+"' style='position:absolute;top:0px;left:0px;"
+"width:1px;height:1px;font-family:arial,sans-serif;font-size:1px'>."
+"<\/div><\/div>");

if (domWw) r = window;
else{
if (d.documentElement &&
typeof d.documentElement.clientWidth == "number" &&
d.documentElement.clientWidth != 0)
r = d.documentElement;
else{
if (d.body &&
typeof d.body.clientWidth == "number")
r = d.body;
}
}

function winsize(){
var oh,sy,ow,sx,rh,rw;
if (domWw){
if (d.documentElement && d.defaultView &&
typeof d.defaultView.scrollMaxY == "number"){
oh = d.documentElement.offsetHeight;
sy = d.defaultView.scrollMaxY;
ow = d.documentElement.offsetWidth;
sx = d.defaultView.scrollMaxX;
rh = oh-sy;
rw = ow-sx;
}
else{
rh = r.innerHeight;
rw = r.innerWidth;
}
h = rh;
w = rw;
}
else{
h = r.clientHeight;
w = r.clientWidth;
}
y = Math.floor(h/2);
x = Math.floor(w/2);

xy = (w >= h)?w:h;
}

function scrl(yx){
var sy,sx;
if (domSy){
sy = r.pageYOffset;
sx = r.pageXOffset;
}
else{
sy = r.scrollTop;
sx = r.scrollLeft;
}
return (yx == 0)?sy:sx;
}

function dsply(){
step += 15;
currentStep += step;

txt.top = y + Math.floor(-currentStep/16) + pix;
txt.left = x + Math.floor(-currentStep/2) + pix;
txt.width = currentStep + pix;
txt.fontSize = Math.floor(currentStep/8) + pix;
txt.color = col[clrPos];
d.getElementById("_txt"+idx).firstChild.data = msg[msgPos];
if (currentStep > xy * xyz){
currentStep = 10;
step = 8;
msgPos += jog;
clrPos += jog;
}
if (clrPos >= col.length){
clrPos = 0;
}
timer = setTimeout(dsply,spd);
if (msgPos >= msg.length){
running = false;
box.width = 1 + pix;
box.height = 1 + pix;
box.visibility = "hidden";
txt.width = 1 + pix;
txt.height = 1 + pix;
txt.visibility = "hidden";
clearTimeout(timer);
}
box.top = scrl(0) + pix;
box.left = scrl(1) + pix;
}
function dims(){
if (domWw) box.width = "100%";
else box.width = w + pix;
box.height = h + pix;
}
function init(){
winsize();
box = document.getElementById("_box"+idx).style;
txt = document.getElementById("_txt"+idx).style;
dims();
dsply();
}

function rsz(){
if (running){
winsize();
dims();
}
}
if (window.addEventListener){
window.addEventListener("resize",rsz,false);
window.addEventListener("load",init,false);
}
else if (window.attachEvent){
window.attachEvent("onresize",rsz);
window.attachEvent("onload",init);
}

})();
}
}//End.
</script>
Jul 23 '05 #5
victor ebuwa wrote:
That's a very old script and, apologies to the author, not a very good
visual effect.

Try this one: - seems to be hidden from Opera though.


Are you trying to tempt me to use a different special effect? Well, it's
working. :-)

Wow! OMG, this one blows me away.

How do you get the text to display even over graphics without affecting
them?

Are you the original author of this script? If so, then I can credit you
with it in the comments.

Yousuf Khan
Jul 23 '05 #6
Michael Winter wrote:
You missed the point. You can get the same effect, just with an
animated image rather than playing around with the font size. An
image will be more accessible (provided that you use the alt
attribute), and it's guaranteed to work almost in every graphical
browser[1]. The same cannot be said for that script, or any other
like it.


Well, the problem with the graphical way you mention is that I'd have to
obtain a GIF animation package, possibly search around for a freeware one
(if freeware GIF animators even exist considering the patents on GIF), and
then to top it off I'd have to learn to use it in a quick amount of time.
Plus in addition to that those facts, adding another GIF image would
necessarily add a large download strain to anybody viewing the page. It's
easy to forget that with broadband that there are dialup users out there
still, where each additional image is a highly noticeable. I do expect
dialup users will be viewing my page too.

Yousuf Khan
Jul 23 '05 #7
"Yousuf Khan" <bb****@ezrs.com> wrote in message news:<tb*****************@twister01.bloor.is.net.c able.rogers.com>...
victor ebuwa wrote:
That's a very old script and, apologies to the author, not a very good
visual effect.

Try this one: - seems to be hidden from Opera though.


Are you trying to tempt me to use a different special effect? Well, it's
working. :-)

Wow! OMG, this one blows me away.

How do you get the text to display even over graphics without affecting
them?

Are you the original author of this script? If so, then I can credit you
with it in the comments.

Yousuf Khan


No I didn't write it. I found it on an email stationary forum a few months ago.
Jul 23 '05 #8
victor ebuwa wrote:
Are you the original author of this script? If so, then I can credit
you with it in the comments.

Yousuf Khan


No I didn't write it. I found it on an email stationary forum a few
months ago.


Okay, then I guess we can call it public domain then. :-)

Yousuf Khan
Jul 23 '05 #9
Yousuf Khan <bb****@ezrs.com> wrote:
Michael Winter wrote:
You missed the point. You can get the same effect, just with an
animated image rather than playing around with the font size. An
image will be more accessible (provided that you use the alt
attribute), and it's guaranteed to work almost in every graphical
browser[1]. The same cannot be said for that script, or any other
like it.


Well, the problem with the graphical way you mention is that I'd have to
obtain a GIF animation package, possibly search around for a freeware one
(if freeware GIF animators even exist considering the patents on GIF), and


Now-expired patents.
Jul 23 '05 #10
Ian Stirling wrote:
Well, the problem with the graphical way you mention is that I'd
have to obtain a GIF animation package, possibly search around for a
freeware one (if freeware GIF animators even exist considering the
patents on GIF), and


Now-expired patents.


Really? So GIF is can now be used for free again?

Yousuf Khan
Jul 23 '05 #11
On 29 Aug 2004 00:41:11 GMT, Ian Stirling <ro**@mauve.demon.co.uk>
wrote:
Yousuf Khan <bb****@ezrs.com> wrote:
Well, the problem with the graphical way you mention is that I'd have to
obtain a GIF animation package, possibly search around for a freeware one
(if freeware GIF animators even exist considering the patents on GIF), and


Now-expired patents.


Is it expired everywhere now? I know US went in 2003, Europe in 2004
(both June time wasn't it?) but does the patent still exist in any
countries?

Jim.
Jul 23 '05 #12
Jim Ley wrote:
On 29 Aug 2004 00:41:11 GMT, Ian Stirling <ro**@mauve.demon.co.uk>
wrote:


Please do not write attribution novels by duplicating header information.
It does not serve any greater purpose but reduces legibility of discussions.
Yousuf Khan <bb****@ezrs.com> wrote:
Well, the problem with the graphical way you mention is that I'd have to
obtain a GIF animation package, possibly search around for a freeware
one (if freeware GIF animators even exist considering the patents on
GIF), and


Now-expired patents.


Is it expired everywhere now? I know US went in 2003, Europe in 2004
(both June time wasn't it?) but does the patent still exist in any
countries?


Unisys' GIF patent expired in the USA, Europe, Japan and Canada,
however the U.S. IBM patent is still valid until August 11, 2006.

<http://www.gnu.org/philosophy/gif.html>
PointedEars
--
But who will take down the flypaper?
Jul 23 '05 #13
Yousuf Khan <bb****@ezrs.com> wrote:
Ian Stirling wrote:
Well, the problem with the graphical way you mention is that I'd
have to obtain a GIF animation package, possibly search around for a
freeware one (if freeware GIF animators even exist considering the
patents on GIF), and


Now-expired patents.


Really? So GIF is can now be used for free again?


I believe so.
Jul 23 '05 #14

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

4 posts views Thread by gemel | last post: by
5 posts views Thread by Velvet | last post: by
reply views Thread by Finn50 | last post: by
1 post views Thread by Solo | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.