sonofslim
Jul 6, 2004, 09:23 PM
i'm trying to build an image gallery, based on the following spec: one main column with a fluid width, containing a horizontally centered image. this image has a fixed position, so that when you scroll the page vertically, it is always visible.
on the right, a fixed-width column containing thumbnails in a vertical line. clicking a thumbnail swaps the main image to the corresponding painting.
the page validates, and works in Safari, IE/Mac, and Firefox Mac + Win. IE/Win, however, chews it up and i have had zero luck fixing it... any suggestions would be greatly appreciated. or any alternate methods of doing this that are more cross-browser compatible and/or elegant, for that matter.
here's the code; i've stripped out some alt attributes and other non-essentials for space. (well... non-essential for functionality, at least.)
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>Oil Paintings</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<style type="text/css">
body {
margin: 0;
padding: 0;
padding-top: 6px;
}
div#main {
position: fixed;
width: 100%;
right: 140px;
top: 34px;
text-align: center;
}
img#mainImage {
position: relative;
left: 75px;
}
div#details {
position: absolute;
right: 2px;
top: 20px;
width: 130px;
}
img.detail {
display: block;
clear: right;
margin-top: 14px;
}
</style>
<script type="text/javascript">
function MM_preloadImages() { //v3.0
var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}
function MM_findObj(n, d) { //v4.01
var p,i,x; if(!d) d=document; if((p=n.indexOf("?"))>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<d.forms.length;i++) x=d.forms[i][n];
for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
if(!x && d.getElementById) x=d.getElementById(n); return x;
}
function MM_swapImage() { //v3.0
var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
</script>
</head>
<body onload="MM_preloadImages('painting_1.jpg','painting_2.jpg','painting_3.jpg','painting_4.jpg','painting_5.jpg ','painting_6.jpg','painting_7.jpg','painting_8.jpg','painting_9.jpg','painting_10.jpg')">
<div id="nav"><a href="index.html"><- main</a></div>
<div id="details">
<a href="painting_1.html" onclick="MM_swapImage('mainImage','','img/painting_1.jpg',1); return false;"><img src="img/thumnbail_1.jpg" class="detail"/></a>
<a href="painting_2.html" onclick="MM_swapImage('mainImage','','img/painting_2.jpg',1); return false;"><img src="img/thumbnail_2.jpg" class="detail"/></a>
<a href="painting_3.html" onclick="MM_swapImage('mainImage','','img/painting_3.jpg',1); return false;"><img src="img/thumnbail_3.jpg" class="detail"/></a>
<a href="painting_4.html" onclick="MM_swapImage('mainImage','','img/painting_4.jpg',1); return false;"><img src="img/thumbnail_4.jpg" class="detail"/></a>
<a href="painting_5.html" onclick="MM_swapImage('mainImage','','img/painting_5.jpg',1); return false;"><img src="img/thumbnail_5.jpg" class="detail"/></a>
<a href="painting_6.html" onclick="MM_swapImage('mainImage','','img/painting_6.jpg',1); return false;"><img src="img/thumbnail_6.jpg" class="detail"/></a>
<a href="painting_7.html" onclick="MM_swapImage('mainImage','','img/painting_7.jpg',1); return false;"><img src="img/thumbnail_7.jpg" class="detail"/></a>
<a href="painting_8.html" onclick="MM_swapImage('mainImage','','img/painting_8.jpg',1); return false;"><img src="img/thumbnail_8.jpg" class="detail"/></a>
<a href="painting_9.html" onclick="MM_swapImage('mainImage','','img/painting_9.jpg',1); return false;"><img src="img/thumbnail_9.jpg" class="detail"/></a>
<a href="painting_10.html" onclick="MM_swapImage('mainImage','','img/painting_10.jpg',1); return false;"><img src="img/thumbnail_10.jpg" class="detail"/></a>
</div>
<div id="main"><img id="mainImage" src="select.gif" name="mainImage" alt="Select an image"/></div>
</body>
</html>
thanks in advance for your brainpower!
on the right, a fixed-width column containing thumbnails in a vertical line. clicking a thumbnail swaps the main image to the corresponding painting.
the page validates, and works in Safari, IE/Mac, and Firefox Mac + Win. IE/Win, however, chews it up and i have had zero luck fixing it... any suggestions would be greatly appreciated. or any alternate methods of doing this that are more cross-browser compatible and/or elegant, for that matter.
here's the code; i've stripped out some alt attributes and other non-essentials for space. (well... non-essential for functionality, at least.)
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>Oil Paintings</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<style type="text/css">
body {
margin: 0;
padding: 0;
padding-top: 6px;
}
div#main {
position: fixed;
width: 100%;
right: 140px;
top: 34px;
text-align: center;
}
img#mainImage {
position: relative;
left: 75px;
}
div#details {
position: absolute;
right: 2px;
top: 20px;
width: 130px;
}
img.detail {
display: block;
clear: right;
margin-top: 14px;
}
</style>
<script type="text/javascript">
function MM_preloadImages() { //v3.0
var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}
function MM_findObj(n, d) { //v4.01
var p,i,x; if(!d) d=document; if((p=n.indexOf("?"))>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<d.forms.length;i++) x=d.forms[i][n];
for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
if(!x && d.getElementById) x=d.getElementById(n); return x;
}
function MM_swapImage() { //v3.0
var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
</script>
</head>
<body onload="MM_preloadImages('painting_1.jpg','painting_2.jpg','painting_3.jpg','painting_4.jpg','painting_5.jpg ','painting_6.jpg','painting_7.jpg','painting_8.jpg','painting_9.jpg','painting_10.jpg')">
<div id="nav"><a href="index.html"><- main</a></div>
<div id="details">
<a href="painting_1.html" onclick="MM_swapImage('mainImage','','img/painting_1.jpg',1); return false;"><img src="img/thumnbail_1.jpg" class="detail"/></a>
<a href="painting_2.html" onclick="MM_swapImage('mainImage','','img/painting_2.jpg',1); return false;"><img src="img/thumbnail_2.jpg" class="detail"/></a>
<a href="painting_3.html" onclick="MM_swapImage('mainImage','','img/painting_3.jpg',1); return false;"><img src="img/thumnbail_3.jpg" class="detail"/></a>
<a href="painting_4.html" onclick="MM_swapImage('mainImage','','img/painting_4.jpg',1); return false;"><img src="img/thumbnail_4.jpg" class="detail"/></a>
<a href="painting_5.html" onclick="MM_swapImage('mainImage','','img/painting_5.jpg',1); return false;"><img src="img/thumbnail_5.jpg" class="detail"/></a>
<a href="painting_6.html" onclick="MM_swapImage('mainImage','','img/painting_6.jpg',1); return false;"><img src="img/thumbnail_6.jpg" class="detail"/></a>
<a href="painting_7.html" onclick="MM_swapImage('mainImage','','img/painting_7.jpg',1); return false;"><img src="img/thumbnail_7.jpg" class="detail"/></a>
<a href="painting_8.html" onclick="MM_swapImage('mainImage','','img/painting_8.jpg',1); return false;"><img src="img/thumbnail_8.jpg" class="detail"/></a>
<a href="painting_9.html" onclick="MM_swapImage('mainImage','','img/painting_9.jpg',1); return false;"><img src="img/thumbnail_9.jpg" class="detail"/></a>
<a href="painting_10.html" onclick="MM_swapImage('mainImage','','img/painting_10.jpg',1); return false;"><img src="img/thumbnail_10.jpg" class="detail"/></a>
</div>
<div id="main"><img id="mainImage" src="select.gif" name="mainImage" alt="Select an image"/></div>
</body>
</html>
thanks in advance for your brainpower!
