Tema: Re: FF, jscript ir <link onload>
Autorius: flegmatoid
Data: 2010-01-13 11:07:37
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META content="text/html; charset=windows-1257" http-equiv=Content-Type>
<META name=GENERATOR content="MSHTML 8.00.6001.18854">
<STYLE></STYLE>
</HEAD>
<BODY bgColor=#c0c0c0>
<DIV><FONT size=2 face=Arial>sitas geras, bet <script> objektai man
problemu nekelia (ten naudojamas tas pats onload event'as
principe).</FONT></DIV>
<DIV><FONT size=2 face=Arial>Gi, apie <link>'us ten nekalbama
....deja</FONT></DIV>
<BLOCKQUOTE
style="BORDER-LEFT: #000000 2px solid; PADDING-LEFT: 5px; PADDING-RIGHT: 0px; MARGIN-LEFT: 5px; MARGIN-RIGHT: 0px"
dir=ltr>
<DIV>"'read only'" <<A
href="mailto:wormazeta@gmaildot.com">wormazeta@gmaildot.com</A>> wrote in
message <A
href="news:hik23i$ac3$1@trimpas.omnitel.net">news:hik23i$ac3$1@trimpas.omnitel.net</A>...</DIV>
<DIV><FONT size=2 face=Arial>Pasidomek LazyLoad</FONT></DIV>
<DIV><FONT size=2 face=Arial><A
href="http://www.appelsiini.net/projects/lazyload">http://www.appelsiini.net/projects/lazyload</A></FONT></DIV>
<DIV><FONT size=2 face=Arial><A
href="http://wonko.com/post/painless_javascript_lazy_loading_with_lazyload">http://wonko.com/post/painless_javascript_lazy_loading_with_lazyload</A></FONT></DIV>
<DIV><FONT size=2 face=Arial>ir t.t.</FONT></DIV>
<BLOCKQUOTE
style="BORDER-LEFT: #000000 2px solid; PADDING-LEFT: 5px; PADDING-RIGHT: 0px; MARGIN-LEFT: 5px; MARGIN-RIGHT: 0px"
dir=ltr>
<DIV>"flegmatoid" <<A
href="mailto:flegmatoid@gmail.com">flegmatoid@gmail.com</A>> wrote in
message <A
href="news:hik1d9$93q$1@trimpas.omnitel.net">news:hik1d9$93q$1@trimpas.omnitel.net</A>...</DIV>
<DIV><FONT size=2 face=Arial>sveiki,</FONT></DIV>
<DIV><FONT size=2 face=Arial></FONT> </DIV>
<DIV><FONT size=2 face=Arial>yra poreikis dinamiskai uzloadinti keleta
css'u ir js'u, jau baigtame loadinti dokumente.</FONT></DIV>
<DIV><FONT size=2 face=Arial>T.y. pradzioje loadiname css'a, po to - eileje
esanty js'a. Sekoje g.b. nuo vieno iki keliolikos failu (mano atveju).
Tikslas - isvengti race condition'u.</FONT></DIV>
<DIV><FONT size=2 face=Arial></FONT> </DIV>
<DIV><FONT size=2 face=Arial><script> objektams pasidariau toki
method'a, kuris lyg ir veikia (FF only realizacija kolkas), gi po FF
<link> objektai irgi palaiko onload event'a, taciau jis
"neissauna"!</FONT></DIV>
<DIV><FONT size=2><FONT face=Arial>("fire "load" event on stylesheet linking
elements when the sheet load finishes" - </FONT><A
href="https://bugzilla.mozilla.org/show_bug.cgi?id=185236"><FONT
face=Arial>https://bugzilla.mozilla.org/show_bug.cgi?id=185236</FONT></A><FONT
face=Arial>)</FONT></FONT></DIV>
<DIV><FONT size=2 face=Arial></FONT> </DIV>
<DIV><FONT size=2 face=Arial>kas matet/girdejot/turit panasu sprendima (ar
seip minciu) stylesheet'u loadinimui - padekit!</FONT></DIV>
<DIV><FONT size=2 face=Arial></FONT> </DIV>
<DIV><FONT size=2 face=Arial>dabar kaip ir tupikas - galvojau pradzioje
<head> vaikus skaiciuoti ir pastebejus pokyti imituoti "onload'a" -
wrong way.</FONT></DIV>
<DIV><FONT size=2 face=Arial>siuo metu bandau document.styleSheets
stebeti, bet ten isvis mistika - matau pastoviai kintanti vaiku skaiciu
- 2;0;3;0;5;0 (loadinant keleta normaliu css'u ir viena dideli (viduje *.php
failo virsuje sleep(20) ideta pvz)).</FONT></DIV>
<DIV><FONT size=2
face="Courier New">_________________________________________________________</FONT></DIV>
<DIV><FONT size=2 face="Courier New"></FONT> </DIV>
<DIV><FONT size=2 face="Courier New">var qLoader={<BR>
queue:false,<BR> load: function () {<BR> if
(!this.queue || this.queue.length==0) return; </FONT></DIV>
<DIV><FONT size=2><BR><FONT face="Courier New"> var
d=document;<BR> var head =
d.getElementsByTagName('head')[0];<BR> var
url=this.queue.shift();</FONT></FONT></DIV>
<DIV><FONT size=2><BR><FONT face="Courier New"> if
(url.match(/js(b?)/g)) {<BR> var obj =
d.createElement('script');<BR> obj.src =
url;<BR>
obj.type='text/javascript';<BR> } else if
(url.match(/css/g)) {<BR> var obj =
d.createElement('link');<BR> obj.href =
url;<BR>
obj.type='text/css';<BR>
obj.rel='stylesheet';<BR> }<BR>
<BR> obj.onload=function() {//sis eventas suveikia
tik <script>, bet ne <link>
objektams<BR>
qLoader.load();<BR> }</FONT></FONT></DIV><FONT size=2
face="Courier New">
<DIV><BR> head.appendChild(obj);<BR> }<BR>}</DIV>
<DIV> </DIV>
<DIV>var objects=[</DIV>
<DIV>'/js/test1.js',</DIV>
<DIV>'/ts/test2.js',</DIV>
<DIV>'/css/style2.css'</DIV>
<DIV>]<BR></DIV>
<DIV>qLoader.queue=objects;</DIV>
<DIV>qLoader.load();</FONT></DIV></BLOCKQUOTE></BLOCKQUOTE></BODY></HTML>