:) 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 <[email protected]> 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 <callto:+61414275989>, > call:+61280113982<callto:+61280113982>, > skype:tathamoddie, msn:[email protected], tatham.oddie.com.au > > > > *From:* [email protected] [mailto:[email protected]] *On > Behalf Of *Brett Patterson > *Sent:* Wednesday, 7 January 2009 12:08 AM > *To:* [email protected] > *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: [email protected] > ******************************************************************* > > ******************************************************************* > List Guidelines: http://webstandardsgroup.org/mail/guidelines.cfm > Unsubscribe: http://webstandardsgroup.org/join/unsubscribe.cfm > Help: [email protected] > ******************************************************************* > ******************************************************************* List Guidelines: http://webstandardsgroup.org/mail/guidelines.cfm Unsubscribe: http://webstandardsgroup.org/join/unsubscribe.cfm Help: [email protected] *******************************************************************
