Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

javascript photo gallery script

Status
Not open for further replies.

ChrissyB

Technical User
Dec 12, 2014
4
US
I wonder if I could get a helping hand with this particular js code that I need for my portfolio gallery?

What I need is after the thumbnail is clicked and the larger image appears, the larger image would include a link at the bottom of the image that would take the viewer to a .pdf file.

Below is the script that I would like to use if possible. If there is any way I can tweak it to do what I need?

<script language="Javascript" type="text/javascript" src="script.js">

window.onload = initAll;

function initAll()
{
for(i=0; i<document.links.length; i++)
{
if(document.links.className == "newWin")
{
document.links.onclick = myNewWindow;
}
}
}

function myNewWindow()
{
var littleWindow = window.open(this.href, "ltWin", "toolbar=no,location=no,status=yes,menubar=no,scrollbars=yes,width=600px,height=600px,left=300px,top=300px");
littleWindow.focus();
return false;
}
</script>
</head>
<body>
<a href="index.html"><img src="home.jpg" alt="home"></a>
<a href="imgbears.jpg" class="newWin"><img src="thimgbears.jpg" alt="picture of bears"></a>
<a href="imgcats.jpg" class="newWin"><img src="thimgcats.jpg" alt="picture of cat"></a>
<a href="imgcheetah.jpg" class="newWin"><img src="thimgcheetah.jpg" alt="picture of cheetah"></a>
<a href="imgdunes.jpg" class="newWin"><img src="thimgdunes.jpg" alt="picture of dunes"></a>
<a href="imggallaxy.jpg" class="newWin"><img src="thimggallaxy.jpg" alt="picture of gallaxy"></a>
<a href="imgjet.jpg" class="newWin"><img src="thimgjet.jpg" alt="picture of jet"></a>
<a href="imgnavy.jpg" class="newWin"><img src="thimgnavy.jpg" alt="picture of navy boat"></a>
<a href="imgocean.jpg" class="newWin"><img src="thimgocean.jpg" alt="picture of ocean"></a>
<a href="imgorion.jpg" class="newWin"><img src="thimgorion.jpg" alt="picture of orion"></a>
<a href="imgtree.jpg" class="newWin"><img src="thimgtree.jpg" alt="picture of tree"></a>
</body>
</html>
 
Audiopro is correct. You are linking directly to the image file so no way to add anything to it like a link.
If you need to show extra html elements like a link to a pdf, then you would need to make the url an actual html page that displays the image along with any other html you need.



As it stands all you are doing is opening the image file in a new Window.

----------------------------------
Phil AKA Vacunita
----------------------------------
Ignorance is not necessarily Bliss, case in point:
Unknown has caused an Unknown Error on Unknown and must be shutdown to prevent damage to Unknown.

Web & Tech
 
Thank you for letting me know.

I got to thinking about it and wondered why I didn't think of that; an html file instead of just an image.
Makes sense.

Again thanks for taking the time to remind me.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top