|
| |
|
|
hoopsking
Posts: 165 Joined: 1/16/2002 From: Status: offline
|
Why does this code not work in a DWT? - 9/29/2007 0:19:39
Why does this code not work inside a DWT applied to a page? It's the Free Drills image rotator on the upper left side. Here is a page without a DWT that it works in:http://www.advancedbasketballtraining.com/index_new.html Here is a page WITH a DWT that it does not work in:http://www.advancedbasketballtraining.com/Basketball_Drills/Basketball_Defense_Drill.html <script language="Javascript"> <!-- var currentdate = 0 var core = 0 function StringArray (n) { this.length = n; for (var i =1; i <= n; i++) { this = ' ' } } image = new StringArray(2) image[0] = '0.jpg' image[1] = '1.jpg' var ran = 60/image.length function ranimage() { currentdate = new Date() core = currentdate.getSeconds() core = Math.floor(core/ran) return(image[core]) } document.write("<img src='" +ranimage()+ "'>") //--> </script> <!--/left menu --><br>
|
|
|
|
Tailslide
Posts: 5915 Joined: 5/10/2005 From: Out here on the raggedy edge Status: offline
|
RE: Why does this code not work in a DWT? - 9/29/2007 3:01:28
Not sure but my guess is it's the path to the image. It seems to be generating this for example: <img src="1.jpg"> But the other page is in a lower folder so it should be this: <img src="../1.jpg"> I think the easiest thing to do given that you want to use this script on multiple folders is to change the script so that it's like this: document.write("<img src='/" +ranimage()+ "'>") With the added "/" it means that the script will always go to the highest folder level to look for the images which is where they are.
_____________________________
"My strategy is so simple an idiot could have devised it" Little Blue Plane Web Design | Blood, Sweat & Rust - A Land Rover restoration project
|
|
|
|
hoopsking
Posts: 165 Joined: 1/16/2002 From: Status: offline
|
RE: Why does this code not work in a DWT? - 9/29/2007 10:23:53
Thank you. That worked.
|
|
|
|
hoopsking
Posts: 165 Joined: 1/16/2002 From: Status: offline
|
RE: Why does this code not work in a DWT? - 9/29/2007 21:50:05
Any idea on how to make one hyperlink open when the image is clicked?
|
|
|
|
Tailslide
Posts: 5915 Joined: 5/10/2005 From: Out here on the raggedy edge Status: offline
|
RE: Why does this code not work in a DWT? - 9/30/2007 3:10:34
What do you mean - open another window showing a larger version of the image or do you mean when an image is clicked then it goes to the relevant web page? If it's the first one - I wouldn't do this, people don't like new windows opening it confuses them. The best solution if you want to show a larger version of an image is to use Lightbox 2 which is really easy to implement and gives a nice effect. If you meant the second thing - basically making an image a link then it's simple, you do this: <a href="yourpage.html"><img src="yourimage.jpg" alt="link to your page" width="whatever" height="whatever" /></a> You will get a border around the image so you'll need to add this to your stylesheet: img {border:none;} Obviously you might sometimes want a border around an image so you might need to give these image links a class and then apply that rule to images with that class.
_____________________________
"My strategy is so simple an idiot could have devised it" Little Blue Plane Web Design | Blood, Sweat & Rust - A Land Rover restoration project
|
|
|
|
hoopsking
Posts: 165 Joined: 1/16/2002 From: Status: offline
|
RE: Why does this code not work in a DWT? - 9/30/2007 21:47:28
I added the link code like this and the picture stopped displaying totally. image = new StringArray(4) image[0] = '0.jpg' <a href="http:/www.hoopsking.com"><img src="0.jpg" alt="link to your page" width="200" height="200" /></a> image[1] = '1.jpg' image[2] = '2.jpg' image[3] = '3.jpg'
|
|
|
|
William Lee
Posts: 1041 Joined: 1/25/2002 From: Singapore Status: offline
|
RE: Why does this code not work in a DWT? - 9/30/2007 22:06:38
quote:
ORIGINAL: hoopsking I added the link code like this and the picture stopped displaying totally. image = new StringArray(4) image[0] = '0.jpg' <a href="http:/www.hoopsking.com"><img src="0.jpg" alt="link to your page" width="200" height="200" /></a> image[1] = '1.jpg' image[2] = '2.jpg' image[3] = '3.jpg' Try put it in the document.write like this: document.write("<a href='http://www.outfront.net'><img src='/" +ranimage()+ "'/></a>")
< Message edited by William Lee -- 9/30/2007 23:30:14 >
|
|
|
|
Tailslide
Posts: 5915 Joined: 5/10/2005 From: Out here on the raggedy edge Status: offline
|
RE: Why does this code not work in a DWT? - 10/1/2007 2:36:28
No hang on - you've got an image link inside a JS array - that's not correct. I didn't realise you were asking how to put a link inside the script rather than just make an image a link. If you want the images to all go to exactly the same page then do what William suggested. If you want different images to go to different pages then you'll need a more complex script like this one: http://www.dynamicdrive.com/dynamicindex14/fadeinslideshow.htm where you can specify different a different link for each image shown.
_____________________________
"My strategy is so simple an idiot could have devised it" Little Blue Plane Web Design | Blood, Sweat & Rust - A Land Rover restoration project
|
|
|
|
hoopsking
Posts: 165 Joined: 1/16/2002 From: Status: offline
|
RE: Why does this code not work in a DWT? - 10/1/2007 10:38:07
Thank you. I only wanted one link and it is now working.
|
|
|
|
William Lee
Posts: 1041 Joined: 1/25/2002 From: Singapore Status: offline
|
RE: Why does this code not work in a DWT? - 10/1/2007 21:45:49
quote:
ORIGINAL: hoopsking Thank you. I only wanted one link and it is now working. I would really love to know if the second suggestion works. If you have the time to try it out, it will be greatly appreciated.
|
|
New Messages |
No New Messages |
Hot Topic w/ New Messages |
Hot Topic w/o New Messages |
Locked w/ New Messages |
Locked w/o New Messages |
|
Post New Thread
Reply to Message
Post New Poll
Submit Vote
Delete My Own Post
Delete My Own Thread
Rate Posts
|
|
|