navigation
a webmaster learning community
     Home    Register     Search      Help      Login    
Sponsors

Shopping Cart Software
Ecommerce software integrated into Frontpage, Dreamweaver and Golive templates. No monthly fees and available in ASP and PHP versions.

Website Templates
We also have a wide selection of Dreamweaver, Expression Web and Frontpage templates as well as webmaster tools and CSS layouts.

Frontpage website templates
Creative Website Templates for FrontPage, Dreamweaver, Flash, SwishMax

Search Forums
 

Advanced search
Recent Posts

 Todays Posts
 Most Active posts
 Posts since last visit
 My Recent Posts
 Mark posts read

Microsoft MVP

 

Why does this code not work in a DWT?

 
View related threads: (in this forum | in all forums)

Logged in as: Guest
Users viewing this topic: none
Printable Version 

All Forums >> Web Development >> Dreamweaver Help >> Why does this code not work in a DWT?
Page: [1]
 
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

(in reply to hoopsking)
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.

(in reply to Tailslide)
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?

(in reply to hoopsking)
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

(in reply to hoopsking)
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 7:00:29   

quote:

ORIGINAL: Tailslide

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.


I'm learning... I'm learning.:)

(in reply to Tailslide)
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'

(in reply to William Lee)
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 >

(in reply to hoopsking)
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

(in reply to William Lee)
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 3:51:30   

Actually he almost got it there first time.
If different images link to different pages, I would suggest doing like this:


image[1]='<a href="http://www.yourdomain.com/page1.html"><img src="/images/1.jpg" alt="link to your page" width="whatever" height="whatever" /></a>'


and then in the document.write, just this:

document.write ranimage()

Worth a try. I can run fast, I'll be out of brickbat range if it doesn't work.:)


< Message edited by William Lee -- 10/1/2007 5:58:13 >

(in reply to Tailslide)
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.

(in reply to hoopsking)
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.

(in reply to hoopsking)
Page:   [1]

All Forums >> Web Development >> Dreamweaver Help >> Why does this code not work in a DWT?
Page: [1]
Jump to: 1





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