On the page inside the iframe, use this version of the script:
Code:
<script type="text/javascript">
/***********************************************
* Image Thumbnail viewer- © Dynamic Drive (www.dynamicdrive.com)
* Last updated Sept 26th, 03'. This notice must stay intact for use
* Visit http://www.dynamicdrive.com/ for full source code
***********************************************/
var ie=document.all
var ns6=document.getElementById&&!document.all
function ietruebody(){
return (document.compatMode && document.compatMode!="BackCompat" && !window.opera)? document.documentElement : document.body
}
function enlarge(which, e, position, imgwidth, imgheight){
if (ie||ns6){
crossobj=document.getElementById? parent.document.getElementById("showimage") : parent.document.all.showimage
if (position=="center"){
pgyoffset=ns6? parseInt(parent.pageYOffset) : parseInt(parent.ietruebody().scrollTop)
horzpos=ns6? parent.pageXOffset+parent.window.innerWidth/2-imgwidth/2 : parent.ietruebody().scrollLeft+parent.ietruebody().clientWidth/2-imgwidth/2
vertpos=ns6? pgyoffset+parent.window.innerHeight/2-imgheight/2 : pgyoffset+parent.ietruebody().clientHeight/2-imgheight/2
if (window.opera && window.innerHeight) //compensate for Opera toolbar
vertpos=pgyoffset+parent.window.innerHeight/2-imgheight/2
vertpos=Math.max(pgyoffset, vertpos)
}
else{
var horzpos=ns6? parent.pageXOffset+e.clientX : parent.ietruebody().scrollLeft+event.clientX
var vertpos=ns6? parent.pageYOffset+e.clientY : parent.ietruebody().scrollTop+event.clientY
}
crossobj.style.left=horzpos+"px"
crossobj.style.top=vertpos+"px"
crossobj.innerHTML='<div align="right" id="dragbar"><span id="closetext" onClick="bud.closepreview()">Close</span> </div><img src="'+which+'">'
crossobj.style.visibility="visible"
return false
}
else //if NOT IE 4+ or NS 6+, simply display image in full browser window
return true
}
function closepreview(){
crossobj.style.visibility="hidden"
}
function drag_drop(e){
if (ie&&dragapproved){
crossobj.style.left=tempx+event.clientX-offsetx+"px"
crossobj.style.top=tempy+event.clientY-offsety+"px"
}
else if (ns6&&dragapproved){
crossobj.style.left=tempx+e.clientX-offsetx+"px"
crossobj.style.top=tempy+e.clientY-offsety+"px"
}
return false
}
function initializedrag(e){
if (ie&&event.srcElement.id=="dragbar"||ns6&&e.target.id=="dragbar"){
offsetx=ie? event.clientX : e.clientX
offsety=ie? event.clientY : e.clientY
tempx=parseInt(crossobj.style.left)
tempy=parseInt(crossobj.style.top)
dragapproved=true
document.onmousemove=drag_drop
}
}
document.onmousedown=initializedrag
document.onmouseup=new Function("dragapproved=false")
</script>
Just for the fun of it and so that the page can be tested independantly (only the close part won't work), include the style section and the:
HTML Code:
<div id="showimage"></div>
as per the instructions on the demo page. Your activating links, of course, also belong on this page.
Now, on the top page, use the style section and the showimage division as well. Also include your iframe (which for this to work, must be named 'bud') and some bootstrap code, here is a demo top page:
Code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/1999/REC-html401-19991224/loose.dtd">
<html>
<head>
<title></title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style type="text/css">
#showimage{
position:absolute;
visibility:hidden;
border: 1px solid gray;
}
#dragbar{
cursor: hand;
cursor: pointer;
background-color: #EFEFEF;
min-width: 100px; /*NS6 style to overcome bug*/
}
#dragbar #closetext{
font-weight: bold;
margin-right: 1px;
}
</style>
</head>
<body>
<div id="showimage"></div>
<iframe name="bud" src="thumb_1.htm" width="100" height="150" scrolling="no" frameborder="0"></iframe>
<script type="text/javascript">
var ie=document.all
var ns6=document.getElementById&&!document.all
function ietruebody(){
return (document.compatMode && document.compatMode!="BackCompat" && !window.opera)? document.documentElement : document.body
}
function drag_drop(e){
if (ie&&dragapproved){
bud.crossobj.style.left=tempx+event.clientX-offsetx+"px"
bud.crossobj.style.top=tempy+event.clientY-offsety+"px"
}
else if (ns6&&dragapproved){
bud.crossobj.style.left=tempx+e.clientX-offsetx+"px"
bud.crossobj.style.top=tempy+e.clientY-offsety+"px"
}
return false
}
function initializedrag(e){
if (ie&&event.srcElement.id=="dragbar"||ns6&&e.target.id=="dragbar"){
offsetx=ie? event.clientX : e.clientX
offsety=ie? event.clientY : e.clientY
tempx=parseInt(bud.crossobj.style.left)
tempy=parseInt(bud.crossobj.style.top)
dragapproved=true
document.onmousemove=drag_drop
}
}
document.onmousedown=initializedrag
document.onmouseup=new Function("dragapproved=false")
</script>
</body>
</html>
Added Info: You can configure your iframe to suit, as long as it is named 'bud'.
Bookmarks