|
|
|||||||||
|
|||||||||
|
|||||||||
| |
|||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
|
|
Stop making mediocre tutorials.The best tutorials are video! Camtasia Studio makes it easy to create engaging, buzz-building screen videos at any size, in any popular format. Download the free trial!
|
|
#1
|
|||
|
|||
|
Problem with images in .js file
I am trying to create a template in Dreamweaver. Because the left navigation bar (which is an uneditable region in the template) contains quite a few links, I've consolidated related links and am using a javascript collapsible menu. My problem is that the images defined in my .js file don't seem to work when I go beyond a certain subfolder in my directory. I am not sure if it is because of the relationship with the template, or what.
My directory structure: Template located in: TDLWeb/templates/TDLTemp.dwt JS file located in: TDLWeb/tdl.js Images located in: TDLWeb/graphics HTM page #1 located in: TDLWeb/home.tdl/tadil1.htm HTM page #2 located in: TDLWeb/home.tdl/home.ccb/ccb1.htm The images all work fine in tadil1.htm (HTM page #1), but when I apply the template to ccb1.htm (HTM page #2), the images are broken. When I click on the image, it should expand the hidden div menu as well as toggle the images. Both pages expand/collapse the menu just fine, but the image problem is driving me crazy. I hope I explained this well enough. Can elaborate further if this is confusing. Here is the javascript code I'm working with in my .js file: function Toggle(item) { obj=document.getElementById(item); visible=(obj.style.display!="none") key=document.getElementById("x" + item); if (visible) { obj.style.display="none"; key.innerHTML="<img src='../graphics/arrowopen.gif' border='0'>"; } else { obj.style.display="block"; key.innerHTML="<img src='../graphics/arrowclose.gif' border='0'>"; } } function Expand() { divs=document.getElementsByTagName("SPAN"); for (i=0;i<divs.length;i++) { divs[i].style.display="block"; key=document.getElementById("x" + divs[i].id); key.innerHTML="<img src='../graphics/arrowclose.gif' border='0'>"; } } function Collapse() { divs=document.getElementsByTagName("SPAN"); for (i=0;i<divs.length;i++) { divs[i].style.display="none"; key=document.getElementById("x" + divs[i].id); key.innerHTML="<img src='../graphics/arrowopen.gif' border='0'>"; } } |
|
#2
|
||||
|
||||
|
maybe if you use complete urls...
try use "file:///c:/anyway/graphics/" instead of "../graphics/" |
|
#3
|
|||
|
|||
|
Quote:
If I tie all of my images to a "local" URL, won't I encounter the same broken image problem if I try and upload all of the files to a different server? |
|
#4
|
||||
|
||||
|
sure. but the idea is to test and, if working well, change the urls before upload.
|
![]() |
| Viewing: Dev Articles Community Forums > Programming > JavaScript Development > Problem with images in .js file |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|