PDA

View Full Version : Hyperlink image in "Snow Effect" script?



Crill
01-15-2010, 01:00 AM
1) Script Title: Snow Effect

2) Script URL (on DD): http://www.dynamicdrive.com/dynamicindex3/snow.htm

3) Describe problem: No problem. The script runs fine. I'm just wondering if it's possible to hyperlink the "snowsrc=" image? I would like to link it to an URL rotator such as "http://xxxxxx.com/mysite/roto.html" and open in a new window.

jscheuer1
01-15-2010, 02:47 PM
Here is where in the script that the images are written out:


if (i == 0) {
document.write("<div id=\"dot"+ i +"\" style=\"POSITION: absolute; Z-INDEX: "+ i +"; VISIBILITY: visible; TOP: 15px; LEFT: 15px;\"><a href=\"http://dynamicdrive.com\"><img src='"+snowsrc+"' border=\"0\"><\/a><\/div>");
} else {
document.write("<div id=\"dot"+ i +"\" style=\"POSITION: absolute; Z-INDEX: "+ i +"; VISIBILITY: visible; TOP: 15px; LEFT: 15px;\"><img src='"+snowsrc+"' border=\"0\"><\/div>");
}


That if (i == 0) and else bit is checking to see if it is the first snowflake, if so it links it to Dynamic Drive:


<a href=\"http://dynamicdrive.com\"><img src='"+snowsrc+"' border=\"0\"><\/a>

You probably want to link all of the snowflakes, if so we can greatly simplify the code (replace all of the code at the top of this post with):


document.write('<div id="dot'+ i +'" style="position: absolute; z-index: '+ i +'; visibility: visible; top: 15px; left: 15px;"><a target="_blank" ' +
'href="http://dynamicdrive.com"' +
'><img src="'+snowsrc+'" border="0"><\/a><\/div>');

Replace http://dynamicdrive.com with the URL to your rotator page.

Crill
01-16-2010, 03:11 AM
Thank You John,
That worked very well. Took me awhile to realize it was working. It's a lot easier for the cursor to catch that small moving image than it is for the browser to catch the link. (I guess) Nevertheless, as long as I click like crazy at the images, they do eventually link through.:D:D:D

Claude