What happened to the Messenger Plus! forums on msghelp.net?
Shoutbox » MsgHelp Archive » Skype & Technology » Tech Talk » im n00b

Pages: (2): « First [ 1 ] 2 » Last »
im n00b
Author: Message:
Supersonicdarky
Veteran Member
*****

Avatar

Posts: 2317
Reputation: 48
– / – / Flag
Joined: Feb 2005
Status: Away
O.P. im n00b
why doesnt this change the width ;<

code:
<html>
<head>
<style type="text/css">
#a, #b, #c {
    height: 10px;
    border: 1px black solid;
    background: #00f;
    margin: 3px;
    display: block;
    }
</style>
</head>

<body>

<script>
document.getElementById('a').style.width="300px";
document.getElementById('b').style.width="400px";
document.getElementById('c').style.width="500px";
</script>

<div id="a"></div>
<div id="b"></div>
<div id="c"></div>
</body>
</html>


* Supersonicdarky phails
06-08-2007 07:57 PM
Profile E-Mail PM Find Quote Report
Nathan
Veteran Member
*****

Avatar
Yeah, "large dimensions" ;)

Posts: 2984
Reputation: 76
– / Male / Flag
Joined: Apr 2005
RE: im n00b
not knowing much about javascript but:

document.getElementById('a').style.width="300px";

should be

document.getElementById('a').innerHTML = "width='300px';";


Im not sure if this will work:

But if I ever use GetElementById()

I always use " " insteas of ' '

This post was edited on 06-08-2007 at 08:03 PM by Nathan.
Touch Innovation - touch friendly programs/applications for the windows mobile!


06-08-2007 08:01 PM
Profile E-Mail PM Web Find Quote Report
Supersonicdarky
Veteran Member
*****

Avatar

Posts: 2317
Reputation: 48
– / – / Flag
Joined: Feb 2005
Status: Away
O.P. RE: im n00b
doesnt work

" doesnt make a difference

head doesnt make a difference

This post was edited on 06-08-2007 at 08:06 PM by Supersonicdarky.
06-08-2007 08:04 PM
Profile E-Mail PM Find Quote Report
Nathan
Veteran Member
*****

Avatar
Yeah, "large dimensions" ;)

Posts: 2984
Reputation: 76
– / Male / Flag
Joined: Apr 2005
RE: im n00b
Try putting the script in the head
Touch Innovation - touch friendly programs/applications for the windows mobile!


06-08-2007 08:05 PM
Profile E-Mail PM Web Find Quote Report
WDZ
Former Admin
*****

Avatar

Posts: 7106
Reputation: 107
– / Male / Flag
Joined: Mar 2002
RE: im n00b
It works for me if I move the <script> block below the divs, or put it in the <head> and execute it onload.
06-08-2007 08:43 PM
Profile PM Web Find Quote Report
Supersonicdarky
Veteran Member
*****

Avatar

Posts: 2317
Reputation: 48
– / – / Flag
Joined: Feb 2005
Status: Away
O.P. RE: im n00b
wtf, why doesnt it work when above divs? ^o)
06-08-2007 09:03 PM
Profile E-Mail PM Find Quote Report
Nathan
Veteran Member
*****

Avatar
Yeah, "large dimensions" ;)

Posts: 2984
Reputation: 76
– / Male / Flag
Joined: Apr 2005
RE: im n00b
try putting it in a function, then calling the funciton:

<script>width();</script>

or try putting in the body tag: onload="width();"

e.g: <body onload="alert('example, you could use your innerHTML stuff instead of this alert.')">

;)

This post was edited on 06-08-2007 at 09:05 PM by Nathan.
Touch Innovation - touch friendly programs/applications for the windows mobile!


06-08-2007 09:04 PM
Profile E-Mail PM Web Find Quote Report
Supersonicdarky
Veteran Member
*****

Avatar

Posts: 2317
Reputation: 48
– / – / Flag
Joined: Feb 2005
Status: Away
O.P. RE: im n00b
it works, but i was wondering why only below
06-08-2007 09:05 PM
Profile E-Mail PM Find Quote Report
Plik
Veteran Member
*****

Avatar

Posts: 1489
Reputation: 46
32 / Male / –
Joined: Jun 2004
RE: im n00b
quote:
Originally posted by Supersonicdarky
wtf, why doesnt it work when above divs? ^o)
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:
Originally posted by Napbree
document.getElementById('a').style.width="300px";

should be

document.getElementById('a').innerHTML = "width='300px';";
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 :P
innerHTML basically lets you access and change all the html within the node.
06-08-2007 09:33 PM
Profile PM Find Quote Report
Felu
Veteran Member
*****


Posts: 2223
Reputation: 72
28 / Male / Flag
Joined: Apr 2006
Status: Away
RE: im n00b
It doesn't work because the script gets executed before the divs are created :rolleyes:.
06-09-2007 10:44 AM
Profile E-Mail PM Web Find Quote Report
Pages: (2): « First [ 1 ] 2 » Last »
« Next Oldest Return to Top Next Newest »


Threaded Mode | Linear Mode
View a Printable Version
Send this Thread to a Friend
Subscribe | Add to Favorites
Rate This Thread:

Forum Jump:

Forum Rules:
You cannot post new threads
You cannot post replies
You cannot post attachments
You can edit your posts
HTML is Off
myCode is On
Smilies are On
[img] Code is On