Why doesn't this script work?
I found a script that I would love to use, but I can't seem to get it to work.
The way it is supposed to behave is when you click on a thumbnail pic on the right, the larger version appears in the larger table to the left, and the larger picture stays there until you click on another thumbnail.
Here's a page where the script works great:
Quote:
<script LANGUAGE="JavaScript">
</script>
But in the page below, it doesn't work. What's wrong with the page below?
NOTE: I only applied the desired behavior to two of the thumbnails in the page below.
Quote:
<script language="JavaScript" type="text/JavaScript">
0&&parent.frames.length) {
d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i</script>
<script LANGUAGE="JavaScript">
</script>
1 ¦ 2
Vincent Puglia posted this at 13:40 — 30th March 2004.
They have: 634 posts
Joined: Dec 1999
Hi Laurie,
Let me start with: That's too much Mickey Mouse code for me to look through. Second, it is not preloading anything. 'Pre' means to do something before something else -- in this case, before loading -- however, since it is in a function that is called with the 'onload' event handler, the loading is actually taking place after the page is displayed. (if you haven't guessed by now, I'm not thrilled with dreamweaver -- I would rather stay awake and write my own code than use its string of spaghetti code
If all you want is to display a larger image when a smaller one is clicked, the following will do just that:
<?php
<script type=\"text/javascript\">
var bin = \"http://members.aol.com/grassblad/images/\"
var picsSrc = new Array(\"grassAvatar.jpg\", \"moi.jpg\");
var pics = new Array();
for (var i = 0; i < picsSrc.length; i++)
{
pics[i] = new Image();
pics[i].src = bin + picsSrc[i];
}
function doit(num)
{
document.theBigPic.src = pics[num].src;
}
</script>
</head>
<body>
<img name=\"theBigPic\" height=\"200\" width=\"200\" src=\"http://members.aol.com/grassblad/images/moiAvatar.jpg\"><br />
<a href=\"#\" onclick=\"doit(0)\"><img src=\"http://members.aol.com/grassblad/images/grassAvatar.jpg\"></a>
<a href=\"#\" onclick=\"doit(1)\"><img src=\"http://members.aol.com/grassblad/images/moiAvatar.jpg\"></a>
</body>
?>
Vinny
Where the world once stood
the blades of grass cut me still
LABachlr posted this at 15:25 — 30th March 2004.
They have: 2 posts
Joined: Mar 2004
First of all, my name is not Laurie. I'm just working on her website. Based on my screenname, I think that you can figure out that I'm a guy.
And thanks for the info, but I already figured it out. All I had to do was change the body tag of the new page to the following and it works perfectly:
If I had more time, I'd compare my code to yours, but I don't. Thanks though.
Vincent Puglia posted this at 21:37 — 30th March 2004.
They have: 634 posts
Joined: Dec 1999
Sorry about the gender mix up; I just grabbed the name from the pics. Regarding your fix: you are still not preloading anything.
Vinny
Want to join the discussion? Create an account or log in if you already have one. Joining is fast, free and painless! We’ll even whisk you back here when you’ve finished.