How do I get javascript to work in .tpl files?
I want to display a logo (in a .tpl file) that has changing images in it so that more than 1 logo image can be displayed (usually upon re-visit to the site).
I have been able to do this in html files with no problem, but this is my first time working with .tpl files and it does not work.
Here's what I've tried so far:
I've placed the following code in a separate .js file and named the file logo.js...
<script LANGUAGE="JavaScript">
');
document.write('');
document.write('');
document.write('' + txt + '');
document.write('');
// End -->
</script>
After placing that code in a separate .js file I use the following code and place it exactly where I want the images to show up...
<script language="text/javaScript" src="logo.js"></script>
But it doesn't work. The page displays fine, but none of the requested images display. (just an empty logo area)
I've checked and re-checked the location address of the js file and images and I believe they are correct.
Also, just so you know. It is VERY important that I be able to control the location of the images because they are my logo images. With that said, placing the javascript code in the HEAD section won't work because I can't control where the images show up (it doesn't work anyways but I thought I mention my reasoning).
Is there a different javascript code that I could be using (instead of the one I'm currently trying)?
Thanks for any responses...
NTG
Jacine posted this at 02:20 — 11th June 2007.
They have: 27 posts
Joined: Mar 2007
Is the JavaScript file and the image files inside the same directory as the .tpl file?
NewTechGuy posted this at 14:32 — 11th June 2007.
He has: 57 posts
Joined: Dec 2004
The javascript file and the images FOLDER are in the same directory. Should I take the images out of the folder and just place them inside the same directory (and NOT in another folder in that same directory?)
UPDATE:
Even though I still can't see the images, I've just discovered that if I use different code to POINT to them the at least I now see the "broken image link" box that appears of the images is NOT showing up. (This is the first time I've seen that and it gives me hope). Now I just need to figure out the correct way to point to my images so that javascript can find them. I'll try a bunch of different things.
Thanks for your response.
NewTechGuy posted this at 15:20 — 11th June 2007.
He has: 57 posts
Joined: Dec 2004
UPDATE:
Even though I still can't see the images, I've just discovered that if I use different code to POINT to them the at least I now see the "broken image link" box that appears of the images is NOT showing up. (This is the first time I've seen that and it gives me hope).
This following is the original code as it looked before I changed it. It used to be coded like this:
banner="/images/logo2.gif;"
But then I CHANGED it to the following and now I can see the "broken image link" box that you see when images don't appear:
banner=" src={$baseurl}/images/logo2.gif;"
Now I just need to figure out the correct way to point to my images so that javascript can find them. I'll try a bunch of different things. Is there anything I should be doing different with this new code to get the images to show up?
Thanks for any responses.
Want to join the discussion? Create an account or log in if you already have one. Joining is fast, free and painless! We’ll even whisk you back here when you’ve finished.