Re: [WSG] JavaScript as External File vs. Internal Code and linking to images

2009-01-06 Thread Ben Buchanan
> Recently, I experimented with changing check boxes with JavaScript. If the
> user clicked on the words next to the check box, then the box would be
> checked, once checked if the user clicked again, then the box would be
> unchecked.

As someone has mentioned, that's precisely what putting the text into a
 does (without the need for any javascript at all). I'm just curious
to know if you are using labels and/or if there was something in your
scenario that meant labels weren't producing the effect you wanted?

-- 
--- 
--- The future has arrived; it's just not
--- evenly distributed. - William Gibson


***
List Guidelines: http://webstandardsgroup.org/mail/guidelines.cfm
Unsubscribe: http://webstandardsgroup.org/join/unsubscribe.cfm
Help: memberh...@webstandardsgroup.org
***

Re: [WSG] JavaScript as External File vs. Internal Code and linking to images

2009-01-06 Thread Brett Patterson
:) I like the disclaimer. Thanks to both of you, that does explain it. By
the way, I am not a JS nut. :) I am "new".

--
Brett P.


On Tue, Jan 6, 2009 at 8:23 AM, Tatham Oddie  wrote:

>  Brett,
>
>
>
> CSS is defining the image links, so the paths are relative to the CSS file
> itself.
>
>
>
> JavaScript is a bit different. It is basically just setting properties on
> the HTML elements and this is no different to setting those properties
> yourself. As such, any image references are relative to the HTML page and
> *not* the JS file.
>
>
>
> Does that help?
>
>
>
>
>
> (Disclaimer: I know this isn't the 100% perfect explanation of DHTML but it
> serves the purpose of answering this question. If you're a JS nut, please
> don't pounce.)
>
>
>
>
>
> Thanks,
>
>
>
> Tatham Oddie
>
> call:+61414275989 , 
> call:+61280113982,
> skype:tathamoddie, msn:tat...@oddie.com.au, tatham.oddie.com.au
>
>
>
> *From:* li...@webstandardsgroup.org [mailto:li...@webstandardsgroup.org] *On
> Behalf Of *Brett Patterson
> *Sent:* Wednesday, 7 January 2009 12:08 AM
> *To:* wsg@webstandardsgroup.org
> *Subject:* [WSG] JavaScript as External File vs. Internal Code and linking
> to images
>
>
>
> Recently, I experimented with changing check boxes with JavaScript. If the
> user clicked on the words next to the check box, then the box would be
> checked, once checked if the user clicked again, then the box would be
> unchecked. I wound up having to apply the same code to the check box itself
> in order to get it to work. In addition, I added code that would change the
> background image of the page to either a solid color, if checked, or back to
> the original image, if unchecked. It did not work. So after changing it some
> more and still getting no results (I think I even asked here), I did some
> research and found another way to link images directly in JavaScript.
> I should make note that all the code was in an external file at the time.
> The following is the structure of the site:
>
> -container (the name of the containing folder for all files)
> ||
> --index.html (home page where the code will be used)
> --scripts (the scripts folder, contains all the scripts)
> |
> ---scripts.js (the scripts file itself)
> ^^
> --styles (stylesheets folder located directly within the container
> folder)
> ||
> ---styles.css (contains style declarations)
> ^^
> --images  (located directly within the container folder)
> |
> ---linkedimage.png (the image to be changed in page background)
>
> I hope the structure above makes sense. Anyway, while linking the image in
> the scripts.js file, I found it never switched back, yet the code never
> showed any problems. When I found the other way to link images directly in
> JavaScript, I changed the image link code to what would amount to being
> directly in the HTML file itself: The first is the original way I linked it
> the second is the new way.
>
>- (../images/linkedimage.png);
>- from above, changed to
>- (images/linkedimage.png);
>
> After the change above, the code worked. I went back to reading about the
> JavaScript standard, I thought that JavaScript was read like an external CSS
> file was read, where you would have to use the (../) part to link to the
> image if it was in a different folder one level above the current folder.
> (as the first line of code above is.) Is that not how JavaScript works? When
> it comes to linked images?
>
> --
> Brett P.
>
>
> ***
> List Guidelines: http://webstandardsgroup.org/mail/guidelines.cfm
> Unsubscribe: http://webstandardsgroup.org/join/unsubscribe.cfm
> Help: memberh...@webstandardsgroup.org
> ***
>
> ***
> List Guidelines: http://webstandardsgroup.org/mail/guidelines.cfm
> Unsubscribe: http://webstandardsgroup.org/join/unsubscribe.cfm
> Help: memberh...@webstandardsgroup.org
> ***
>


***
List Guidelines: http://webstandardsgroup.org/mail/guidelines.cfm
Unsubscribe: http://webstandardsgroup.org/join/unsubscribe.cfm
Help: memberh...@webstandardsgroup.org
***

RE: [WSG] JavaScript as External File vs. Internal Code and linking to images

2009-01-06 Thread Tatham Oddie
Brett,

 

CSS is defining the image links, so the paths are relative to the CSS file
itself.

 

JavaScript is a bit different. It is basically just setting properties on
the HTML elements and this is no different to setting those properties
yourself. As such, any image references are relative to the HTML page and
not the JS file.

 

Does that help?

 

 

(Disclaimer: I know this isn't the 100% perfect explanation of DHTML but it
serves the purpose of answering this question. If you're a JS nut, please
don't pounce.)

 

 

Thanks,

 

Tatham Oddie

  call:+61414275989,  
call:+61280113982,   skype:tathamoddie,
 msn:tat...@oddie.com.au,
<http://tatham.oddie.com.au/> tatham.oddie.com.au

 

From: li...@webstandardsgroup.org [mailto:li...@webstandardsgroup.org] On
Behalf Of Brett Patterson
Sent: Wednesday, 7 January 2009 12:08 AM
To: wsg@webstandardsgroup.org
Subject: [WSG] JavaScript as External File vs. Internal Code and linking to
images

 

Recently, I experimented with changing check boxes with JavaScript. If the
user clicked on the words next to the check box, then the box would be
checked, once checked if the user clicked again, then the box would be
unchecked. I wound up having to apply the same code to the check box itself
in order to get it to work. In addition, I added code that would change the
background image of the page to either a solid color, if checked, or back to
the original image, if unchecked. It did not work. So after changing it some
more and still getting no results (I think I even asked here), I did some
research and found another way to link images directly in JavaScript. 
I should make note that all the code was in an external file at the time.
The following is the structure of the site:

-container (the name of the containing folder for all files)
||
--index.html (home page where the code will be used)
--scripts (the scripts folder, contains all the scripts)
|
---scripts.js (the scripts file itself)
^^
--styles (stylesheets folder located directly within the container
folder)
||
---styles.css (contains style declarations)
^^
--images  (located directly within the container folder)
|
---linkedimage.png (the image to be changed in page background)

I hope the structure above makes sense. Anyway, while linking the image in
the scripts.js file, I found it never switched back, yet the code never
showed any problems. When I found the other way to link images directly in
JavaScript, I changed the image link code to what would amount to being
directly in the HTML file itself: The first is the original way I linked it
the second is the new way.

*   (../images/linkedimage.png);
*   from above, changed to
*   (images/linkedimage.png);

After the change above, the code worked. I went back to reading about the
JavaScript standard, I thought that JavaScript was read like an external CSS
file was read, where you would have to use the (../) part to link to the
image if it was in a different folder one level above the current folder.
(as the first line of code above is.) Is that not how JavaScript works? When
it comes to linked images?

--
Brett P.

***
List Guidelines: http://webstandardsgroup.org/mail/guidelines.cfm
Unsubscribe: http://webstandardsgroup.org/join/unsubscribe.cfm
Help: memberh...@webstandardsgroup.org
***



***
List Guidelines: http://webstandardsgroup.org/mail/guidelines.cfm
Unsubscribe: http://webstandardsgroup.org/join/unsubscribe.cfm
Help: memberh...@webstandardsgroup.org
***

Re: [WSG] JavaScript as External File vs. Internal Code and linking to images

2009-01-06 Thread David Dorward

Brett Patterson wrote:
Recently, I experimented with changing check boxes with JavaScript. If 
the user clicked on the words next to the check box, then the box 
would be checked, once checked if the user clicked again, then the box 
would be unchecked.

Sounds like a  would have been easier.

I thought that JavaScript was read like an external CSS file was read, 
where you would have to use the (../) part to link to the image if it 
was in a different folder one level above the current folder. (as the 
first line of code above is.) Is that not how JavaScript works? When 
it comes to linked images?
You aren't reading the resource at the URL from JavaScript though - you 
are changing the DOM so it references a different URL (and it is still 
using the URI of the HTML document as a base).



--
David Dorward
http://dorward.me.uk/



***
List Guidelines: http://webstandardsgroup.org/mail/guidelines.cfm
Unsubscribe: http://webstandardsgroup.org/join/unsubscribe.cfm
Help: memberh...@webstandardsgroup.org
***



[WSG] JavaScript as External File vs. Internal Code and linking to images

2009-01-06 Thread Brett Patterson
Recently, I experimented with changing check boxes with JavaScript. If the
user clicked on the words next to the check box, then the box would be
checked, once checked if the user clicked again, then the box would be
unchecked. I wound up having to apply the same code to the check box itself
in order to get it to work. In addition, I added code that would change the
background image of the page to either a solid color, if checked, or back to
the original image, if unchecked. It did not work. So after changing it some
more and still getting no results (I think I even asked here), I did some
research and found another way to link images directly in JavaScript.
I should make note that all the code was in an external file at the time.
The following is the structure of the site:

-container (the name of the containing folder for all files)
||
--index.html (home page where the code will be used)
--scripts (the scripts folder, contains all the scripts)
|
---scripts.js (the scripts file itself)
^^
--styles (stylesheets folder located directly within the container
folder)
||
---styles.css (contains style declarations)
^^
--images  (located directly within the container folder)
|
---linkedimage.png (the image to be changed in page background)

I hope the structure above makes sense. Anyway, while linking the image in
the scripts.js file, I found it never switched back, yet the code never
showed any problems. When I found the other way to link images directly in
JavaScript, I changed the image link code to what would amount to being
directly in the HTML file itself: The first is the original way I linked it
the second is the new way.

   - (../images/linkedimage.png);
   - from above, changed to
   - (images/linkedimage.png);

After the change above, the code worked. I went back to reading about the
JavaScript standard, I thought that JavaScript was read like an external CSS
file was read, where you would have to use the (../) part to link to the
image if it was in a different folder one level above the current folder.
(as the first line of code above is.) Is that not how JavaScript works? When
it comes to linked images?

--
Brett P.


***
List Guidelines: http://webstandardsgroup.org/mail/guidelines.cfm
Unsubscribe: http://webstandardsgroup.org/join/unsubscribe.cfm
Help: memberh...@webstandardsgroup.org
***