Image Swap onClick Opens Image in Parent Window

Tags: , , , , , , , , , , ,
Posted in dotnet, vb, vb.net | 9 Comments »

I’m trying to use javascript to load an image on a webpage when another image is clicked on, just like an image gallery and just like this except I don’t need any text:

http://javascript.internet.com/image…e-gallery.html

I copied the example above but when I click on the smaller image to load the larger one it works for a fraction of a second (I can see the image load in the right spot), but then the browser goes to the URL of the image instead (showing it on a blank page).

See what I mean here:

http://www.keeneysandandstone.com/boulders-js.html

Clickin on one of the smaller boulder images is supposed to load the larger version of that image below.

Related code:

imageGallery.js

/* This script and many more are available free online at
The JavaScript Source!! http://javascript.internet.com
Created by: Jeremy Keith / Anonymous | http://www.alistapart.com/articles/imagegallery/ */
function showPic(whichpic) {
if (document.getElementById) {
document.getElementById(‘placeholder’).src = whichpic.href;
if (whichpic.title) {
document.getElementById(‘desc’).childNodes[0].nodeValue = whichpic.title;
} else {
document.getElementById(‘desc’).childNodes[0].nodeValue = whichpic.childNodes[0].nodeValue;
}
return false;
} else {
return true;
}
}

HTML

Head:

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

Body:

<table width="900" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="25%" align="center"><a onclick="showPic(this); return false;" href="images/boulder1.jpg" /><img src="images/boulder1-thumb.jpg" width="197" height="125" /></a></td>
<td width="25%" align="center"><a onclick="showPic(this); return false;" href="images/boulder2.jpg" /><img src="images/boulder2-thumb.jpg" width="197" height="125" /></a></td>
<td width="25%" align="center"><a onclick="showPic(this); return false;" href="images/boulder3.jpg" /><img src="images/boulder3-thumb.jpg" width="197" height="125" /></a></td>
<td width="25%" align="center"><a onclick="showPic(this); return false;" href="images/boulder4.jpg" /><img src="images/boulder4-thumb.jpg" width="197" height="125" /></a></td>
</tr>
</table>

Where the image should load:

<img id="placeholder" src="images/boulder1.jpg">

Any help appreciated. I’m not a programmer, just a designer, and this has stumped me.

Thanks!

Similar:

  1. image onclick event <asp:GridView ID="gvOfferedProductDetails" runat="server" AutoGenerateColumns="false"                     Width="500" HeaderStyle-CssClass="tableHead" OnRowDataBound="gvOfferedProductDetails_RowDataBound">                   ...
  2. Change background image and div content with ajax Hi All hope you can help its been driving me crazy .. i have a website where i change the content of a div using...
  3. How do I pass the file names (from child window) back to an html page (parent window)? I have an html (not aspx) page which opens up a pop-up window (Child.aspx page) to upload files.  I have everything working but don't know...
  4. how to fix the window size even image position outside the box? http://img227.imageshack.us/img227/3553/whitespace.png http://img704.imageshack.us/img704/4586/leftii.png I'm developing a website. I've position some image using CSS. i've set the background to 100% but when my the image i position...
  5. rollover image swap function Hey Everyone, I am trying to write a simple function that will apply a rollover function to certain images. It seems that the onmouseover and...

Tags: , , , , , , , , , , ,

9 Responses to “Image Swap onClick Opens Image in Parent Window”

  1. [...] Image Swap onClick Opens Image in Parent Window | The Largest … [...]

  2. [...] Image Swap onClick Opens Image &#1110&#1495 Parent Window | T&#1211&#1077 L&#1072r&#609&#1077&#1109t… [...]

  3. [...] Image Swap onClick Opens Image in Parent Window | The Largest … [...]

  4. [...] Image Swap onClick Opens Image in Parent Window | The Largest … [...]

  5. [...] Image Swap onClick Opens Image &#1110&#1495 Parent Window | T&#1211&#1077 L&#1072r&#609&#1077&#1109t… [...]

  6. [...] Image Swap onClick Opens Image in Parent Window | The Largest … [...]

  7. [...] Image Swap onClick Opens Image in Parent Window | The Largest … [...]

  8. [...] Image Swap onClick Opens Image in Parent Window | The Largest … [...]

  9. [...] Image Swap onClick Opens Image in Parent Window | The Largest … [...]

Leave a Reply