Old 06-02-2008, 06:12   #1 (permalink)
zealot206
Zealot
 
zealot206's Avatar
 
Join Date: Jan 2008
Location: Malaysia
Posts: 18
Send a message via Skype™ to zealot206
Java Script

A couple of monts ago, I tried out a snow javascript from hypergurl to create a website, HTML codes, generators, javascripts for my web site. It was ok at first, but once I use the XHTML 1.0 DTD, the script stopped working. Can anybody help me? I want to use the script together with the XHTML 1.0 DTD.

This is the script:
Quote:
<script>
// CREDITS:
// Snowmaker Copyright (c) 2003 Peter Gehrig. All rights reserved.
// Distributed by hypergurl.com Web tools to create a website, HTML codes, generators, javascripts
// Permission given to use the script provided that this notice remains as is.

// Set the number of snowflakes (more than 30 - 40 not recommended)
var snowmax=35

// Set the colors for the snow. Add as many colors as you like
var snowcolor=new Array("#aaaacc","#ddddFF","#ccccDD")

// Set the fonts, that create the snowflakes. Add as many fonts as you like
var snowtype=new Array("Arial Black","Arial Narrow","Times","Comic Sans MS")

// Set the letter that creates your snowflake (recommended:*)
var snowletter="*"

// Set the speed of sinking (recommended values range from 0.3 to 2)
var sinkspeed=0.6

// Set the maximal-size of your snowflaxes
var snowmaxsize=22

// Set the minimal-size of your snowflaxes
var snowminsize=8

// Set the snowing-zone
// Set 1 for all-over-snowing, set 2 for left-side-snowing
// Set 3 for center-snowing, set 4 for right-side-snowing
var snowingzone=1

///////////////////////////////////////////////////////////////////////////
// CONFIGURATION ENDS HERE
///////////////////////////////////////////////////////////////////////////


// Do not edit below this line
var snow=new Array()
var marginbottom
var marginright
var timer
var i_snow=0
var x_mv=new Array();
var crds=new Array();
var lftrght=new Array();
var browserinfos=navigator.userAgent
var ie5=document.all&&document.getElementById&&!browse rinfos.match(/Opera/)
var ns6=document.getElementById&&!document.all
var opera=browserinfos.match(/Opera/)
var browserok=ie5||ns6||opera

function randommaker(range) {
rand=Math.floor(range*Math.random())
return rand
}

function initsnow() {
if (ie5 || opera) {
marginbottom = document.body.clientHeight
marginright = document.body.clientWidth
}
else if (ns6) {
marginbottom = window.innerHeight
marginright = window.innerWidth
}
var snowsizerange=snowmaxsize-snowminsize
for (i=0;i<=snowmax;i++) {
crds[i] = 0;
lftrght[i] = Math.random()*15;
x_mv[i] = 0.03 + Math.random()/10;
snow[i]=document.getElementById("s"+i)
snow[i].style.fontFamily=snowtype[randommaker(snowtype.length)]
snow[i].size=randommaker(snowsizerange)+snowminsize
snow[i].style.fontSize=snow[i].size
snow[i].style.color=snowcolor[randommaker(snowcolor.length)]
snow[i].sink=sinkspeed*snow[i].size/5
if (snowingzone==1) {snow[i].posx=randommaker(marginright-snow[i].size)}
if (snowingzone==2) {snow[i].posx=randommaker(marginright/2-snow[i].size)}
if (snowingzone==3) {snow[i].posx=randommaker(marginright/2-snow[i].size)

+marginright/4}
if (snowingzone==4) {snow[i].posx=randommaker(marginright/2-snow[i].size)

+marginright/2}
snow[i].posy=randommaker(6*marginbottom-marginbottom-6*snow[i].size)
snow[i].style.left=snow[i].posx
snow[i].style.top=snow[i].posy
}
movesnow()
}

function movesnow() {
for (i=0;i<=snowmax;i++) {
crds[i] += x_mv[i];
snow[i].posy+=snow[i].sink
snow[i].style.left=snow[i].posx+lftrght[i]*Math.sin(crds[i]);
snow[i].style.top=snow[i].posy

if (snow[i].posy>=marginbottom-6*snow[i].size || parseInt(snow

[i].style.left)>(marginright-3*lftrght[i])){
if (snowingzone==1) {snow[i].posx=randommaker(marginright-snow

[i].size)}
if (snowingzone==2) {snow[i].posx=randommaker(marginright/2-snow

[i].size)}
if (snowingzone==3) {snow[i].posx=randommaker(marginright/2-snow

[i].size)+marginright/4}
if (snowingzone==4) {snow[i].posx=randommaker(marginright/2-snow

[i].size)+marginright/2}
snow[i].posy=0
}
}
var timer=setTimeout("movesnow()",50)
}

for (i=0;i<=snowmax;i++) {
document.write("<span id='s"+i+"' style='position:absolute;top:

-"+snowmaxsize+"'>"+snowletter+"</span>")
}
if (browserok) {
window.onload=initsnow
}
</script>
  Reply With Quote
Old 06-02-2008, 06:33   #2 (permalink)
djeglin
goober :-)
 
djeglin's Avatar
 
Join Date: Dec 2006
Location: Birmingham, UK
Posts: 532
Send a message via MSN to djeglin
Not being funny.... but why would you even want to use a snow script? So 1999....

Anyway, the reason it wont work is because the script is using the (horribly outdated) document.write method. This doesnt work with XHTML, because of the way XML (Which XHTML is a subset of) works. You'd have to use a script that used DOM methods instead to achieve the same effect.

Like I said though... so 1999...
__________________
My signature sucks.
  Reply With Quote
Old 07-02-2008, 10:20   #3 (permalink)
zealot206
Zealot
 
zealot206's Avatar
 
Join Date: Jan 2008
Location: Malaysia
Posts: 18
Send a message via Skype™ to zealot206
What to do?

Whay I used it, is none of your business! I don't care wheter it is 1999 or 2008! I politely asked for your help and u guys just laugh insted of helping! So, what am I supposed to do with the snow script?!
  Reply With Quote
Old 07-02-2008, 10:28   #4 (permalink)
Shiro
shiro
 
Shiro's Avatar
 
Join Date: Aug 2007
Location: Yokohama, Japan
Posts: 3,427
Either change your doctype from XHTML, scrap that script, or learn enough javascript to be able to re-write it using current standards.
  Reply With Quote
Old 07-02-2008, 10:40   #5 (permalink)
djeglin
goober :-)
 
djeglin's Avatar
 
Join Date: Dec 2006
Location: Birmingham, UK
Posts: 532
Send a message via MSN to djeglin
whoa there, zealot... I made a comment that its perhaps not something that you would want to use if you want to keep in with current taste... But then I told you why the script isnt working. You cant use an xhtml doctype with document.write javascript methods, so you have three choices: Either scrap the xhtml doctype, modify the current script to use DOM methods instead, or find a new script.

To put it simply, to explain the ins and outs of how to rewite the script, would basically mean me rewriting it myself... And I'm afraid I just dont have the time right now. I tried to be as helpful as I could given the time I have available, but I guess for you thats not enough...

My comment stands, though, about it being "1999"... I was trying to steer you away from doing something that will ultimately look tacky, hog client side resources (cause javascript animation tends to do that), and generally be annoying to most consumers. No need to throw your toys out of the pram, now, is there?
__________________
My signature sucks.
  Reply With Quote
Old 09-02-2008, 00:44   #6 (permalink)
zealot206
Zealot
 
zealot206's Avatar
 
Join Date: Jan 2008
Location: Malaysia
Posts: 18
Send a message via Skype™ to zealot206
SRY bout that...

Sorry about that... It is just that I went to a lot of forums, but people just ignore or criticise my post. Is there any other way?!
  Reply With Quote
Old 09-02-2008, 07:50   #7 (permalink)
Bill Posters
trouble free and loverlee
 
Join Date: Mar 2003
Location: YooKay
Posts: 2,975
Quote:
Originally Posted by djeglin
the reason it wont work is because the script is using the (horribly outdated) document.write method. This doesnt work with XHTML, because of the way XML (Which XHTML is a subset of) works.
Simply switching to an XHTML doctype doesn't make a document XML. It's the mime-type that makes all the difference.
It's possible that the OP's XHTML markup is still being sent as text/html (i.e. as HTML, but with slight errors). If so, then, as nasty as the method is, document.write should technically still work.

(It's not until you start serving the XHTML markup using an XML-based mime-type that things which aren't supposed to work actually stop working - though, in reality, a number of them continue to work).

Switching to an XHTML (Strict?) DTD can alter how the browser handles and interacts with the DOM. The same can be said when switching from any Transitional doctype to a Strict doctype.

Quote:
You'd have to use a script that used DOM methods instead to achieve the same effect.
Not necessarily, but it's the safest bet.
  Reply With Quote
Old 10-02-2008, 23:40   #8 (permalink)
djeglin
goober :-)
 
djeglin's Avatar
 
Join Date: Dec 2006
Location: Birmingham, UK
Posts: 532
Send a message via MSN to djeglin
Bill,

Just to clarify for myself, as far as I know, what you said is only true for IE based browsers, where they ignore the DTD, essentially? In Gekko / Webkit etc based browsers, they will read the DTD and, whilst maybe not serving the document as XML per se, still treat it as such where it applies to the physical rendering of the page?

Gah... I hate all this stuff... The fact that different browsers make the page look different is bad enough for those of us who do this every day, but to have browsers physically treating documents as different things? Its stupid. MS has said pretty much outright that they have no plans to further support DTDs, which means on that front we're pretty much stuck in the mud!
__________________
My signature sucks.
  Reply With Quote
Old 11-02-2008, 03:56   #9 (permalink)
Bill Posters
trouble free and loverlee
 
Join Date: Mar 2003
Location: YooKay
Posts: 2,975
Quote:
Originally Posted by djeglin
Bill,

Just to clarify for myself, as far as I know, what you said is only true for IE based browsers, where they ignore the DTD, essentially? In Gekko / Webkit etc based browsers, they will read the DTD and, whilst maybe not serving the document as XML per se, still treat it as such where it applies to the physical rendering of the page?
I can absolutely say that this is not true.
'Proper' XML will return the yellow error page on a malformed document. This only occurs when served as XML. Using an XHTML doctype will not trigger this level of XML compliance in any browser, afaik.
Additionally, methods such as document.write continue to work so long as the markup is served as text/html, regardless of the doctype used.

No version of IE can, as yet, handle application/xhtml+xml correctly, which is the mime-type typically used to serve XHTML markup as XML.

It's certainly true that different DTDs can trigger different levels of rendering compliance in different browsers. This is why I invariably stick with full, Strict doctypes - typically XHTML Strict - in order to ensure that all browsers are on their best behaviour.

IE browsers certainly do not ignore the DTD. The DTD is possibly more important in IE than in any other browsers. Only when a full and valid DTD is in place do browsers such as IE6 and IE7 enter compliant mode, rendering box models correctly.
Other browsers, such as Gecko and Web-Kit based browsers, tend to default to a greater level of compliant rendering, even in the absence of a DTD.

Those may be the discrepencies which you had in mind.
  Reply With Quote
Old 11-02-2008, 05:37   #10 (permalink)
djeglin
goober :-)
 
djeglin's Avatar
 
Join Date: Dec 2006
Location: Birmingham, UK
Posts: 532
Send a message via MSN to djeglin
hehe... they may be... i was very tired when i wrote that!
__________________
My signature sucks.
  Reply With Quote
Old 11-02-2008, 08:54   #11 (permalink)
zealot206
Zealot
 
zealot206's Avatar
 
Join Date: Jan 2008
Location: Malaysia
Posts: 18
Send a message via Skype™ to zealot206
I tried...

Bill, I already try with different DTDs but they are hardly any difference at all...
  Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search


Contact Us - Web Design Forums - Archive - Top
Search Engine Optimization by vBSEO 3.0.0 RC8