im n00b - Printable Version -Shoutbox (https://shoutbox.menthix.net) +-- Forum: MsgHelp Archive (/forumdisplay.php?fid=58) +--- Forum: Skype & Technology (/forumdisplay.php?fid=9) +---- Forum: Tech Talk (/forumdisplay.php?fid=17) +----- Thread: im n00b (/showthread.php?tid=75191) im n00b by Supersonicdarky on 06-08-2007 at 07:57 PM
why doesnt this change the width ;< code: * Supersonicdarky phails RE: im n00b by Nathan on 06-08-2007 at 08:01 PM
not knowing much about javascript but: RE: im n00b by Supersonicdarky on 06-08-2007 at 08:04 PM
doesnt work RE: im n00b by Nathan on 06-08-2007 at 08:05 PM Try putting the script in the head RE: im n00b by WDZ on 06-08-2007 at 08:43 PM It works for me if I move the <script> block below the divs, or put it in the <head> and execute it onload. RE: im n00b by Supersonicdarky on 06-08-2007 at 09:03 PM wtf, why doesnt it work when above divs? RE: im n00b by Nathan on 06-08-2007 at 09:04 PM
try putting it in a function, then calling the funciton: RE: im n00b by Supersonicdarky on 06-08-2007 at 09:05 PM it works, but i was wondering why only below RE: im n00b by Plik on 06-08-2007 at 09:33 PM
quote:Because the JS is excecuted when the parser gets to that node, at which point the DIVs don't exist, because the page hasn't loaded fully. Therefore when the JS is excecuted the DIVs can't be found, but when the script node is below the DIVs then they do exist. You can have the JS above the divs by using onload like Nathen said. quote:nonononono way! The first one is right, the second one will set the contents of the a div to "width='300px';", and wont change the width innerHTML basically lets you access and change all the html within the node. RE: im n00b by Felu on 06-09-2007 at 10:44 AM It doesn't work because the script gets executed before the divs are created . RE: im n00b by markee on 06-09-2007 at 11:35 AM and this is why you should put javascript in a function and execute it with an onload attribute of the body.... |