G
Gary
Can somebody help me get the onMouseOut to work in this script? The
onMouseOver works great opening a new window with an image, but I'd like to
get the popup window to close onMouseOut. Is this possible? I'm guessing
it's not because the parent window loses focus when the popup opens.
Is there a better way to do this? I have thumbnails of my kids that I want
to open in a larger format when hoverer over so the grandparents can see
them better. I'd really like to have the images open as a watermark if
that's possible. I'm currently using:
<img src="/pics/oppsb.jpg" width="56" height="80" name="myImage"
onMouseover="javascript:myImage.height=160;myImage.width=112"
onMouseout="javascript:myImage.width=56;myImage.height=80">
But whenever I add an image I have to change "myImage(last)" to
"myImage(+1)". Which, when I organize the photos it takes forever to find
the last one.
Here's what I'm working with. It works great, like I said, to open a
window, but I can't get it to close without clicking the X. Any ideas?
<script type="text/javascript">
// JK Pop up image viewer script- By JavaScriptKit.com
// Visit JavaScript Kit (http://javascriptkit.com)
// for free JavaScript tutorials and scripts
// This notice must stay intact for use
var popbackground="lightskyblue" //specify backcolor or background image for
pop window
var windowtitle="Image Window" //pop window title
function detectexist(obj){
return (typeof obj !="undefined")
}
function jkpopimage(imgpath, popwidth, popheight, textdescription){
function getpos(){
leftpos=(detectexist(window.screenLeft))?
screenLeft+document.body.clientWidth/1-popwidth/2-popwidth :
detectexist(window.screenX)? screenX+innerWidth/2-popwidth/2 : 0
toppos=(detectexist(window.screenTop))?
screenTop+document.body.clientHeight/100-popheight/2 :
detectexist(window.screenY)? screenY+innerHeight/2-popheight/2 : 0
if (window.opera){
leftpos-=screenLeft
toppos-=screenTop
}
}
getpos()
var
winattributes='width='+popwidth+',height='+popheight+',resizable=yes,left='+leftpos+',top='+toppos
var bodyattribute=(popbackground.indexOf(".")!=-1)?
'background="'+popbackground+'"' : 'bgcolor="'+popbackground+'"'
if (typeof jkpopwin=="undefined" || jkpopwin.closed)
jkpopwin=window.open("","",winattributes)
else{
//getpos() //uncomment these 2 lines if you wish subsequent popups to be
centered too
//jkpopwin.moveTo(leftpos, toppos)
jkpopwin.resizeTo(popwidth, popheight+30)
}
jkpopwin.document.open()
jkpopwin.document.write('<html><title>'+windowtitle+'</title><body
'+bodyattribute+'><img src="'+imgpath+'" style="margin-bottom:
0.5em"><br>'+textdescription+'</body></html>')
jkpopwin.document.close()
jkpopwin.focus()
}
</script>
<img src="/pics/oppsb.jpg" width="56" height="80"
onMouseover="jkpopimage('pics/oppsb.jpg', 250, 410, 'OPPSb'); return false"
onMouseout="jkpopimage.close();">
onMouseOver works great opening a new window with an image, but I'd like to
get the popup window to close onMouseOut. Is this possible? I'm guessing
it's not because the parent window loses focus when the popup opens.
Is there a better way to do this? I have thumbnails of my kids that I want
to open in a larger format when hoverer over so the grandparents can see
them better. I'd really like to have the images open as a watermark if
that's possible. I'm currently using:
<img src="/pics/oppsb.jpg" width="56" height="80" name="myImage"
onMouseover="javascript:myImage.height=160;myImage.width=112"
onMouseout="javascript:myImage.width=56;myImage.height=80">
But whenever I add an image I have to change "myImage(last)" to
"myImage(+1)". Which, when I organize the photos it takes forever to find
the last one.
Here's what I'm working with. It works great, like I said, to open a
window, but I can't get it to close without clicking the X. Any ideas?
<script type="text/javascript">
// JK Pop up image viewer script- By JavaScriptKit.com
// Visit JavaScript Kit (http://javascriptkit.com)
// for free JavaScript tutorials and scripts
// This notice must stay intact for use
var popbackground="lightskyblue" //specify backcolor or background image for
pop window
var windowtitle="Image Window" //pop window title
function detectexist(obj){
return (typeof obj !="undefined")
}
function jkpopimage(imgpath, popwidth, popheight, textdescription){
function getpos(){
leftpos=(detectexist(window.screenLeft))?
screenLeft+document.body.clientWidth/1-popwidth/2-popwidth :
detectexist(window.screenX)? screenX+innerWidth/2-popwidth/2 : 0
toppos=(detectexist(window.screenTop))?
screenTop+document.body.clientHeight/100-popheight/2 :
detectexist(window.screenY)? screenY+innerHeight/2-popheight/2 : 0
if (window.opera){
leftpos-=screenLeft
toppos-=screenTop
}
}
getpos()
var
winattributes='width='+popwidth+',height='+popheight+',resizable=yes,left='+leftpos+',top='+toppos
var bodyattribute=(popbackground.indexOf(".")!=-1)?
'background="'+popbackground+'"' : 'bgcolor="'+popbackground+'"'
if (typeof jkpopwin=="undefined" || jkpopwin.closed)
jkpopwin=window.open("","",winattributes)
else{
//getpos() //uncomment these 2 lines if you wish subsequent popups to be
centered too
//jkpopwin.moveTo(leftpos, toppos)
jkpopwin.resizeTo(popwidth, popheight+30)
}
jkpopwin.document.open()
jkpopwin.document.write('<html><title>'+windowtitle+'</title><body
'+bodyattribute+'><img src="'+imgpath+'" style="margin-bottom:
0.5em"><br>'+textdescription+'</body></html>')
jkpopwin.document.close()
jkpopwin.focus()
}
</script>
<img src="/pics/oppsb.jpg" width="56" height="80"
onMouseover="jkpopimage('pics/oppsb.jpg', 250, 410, 'OPPSb'); return false"
onMouseout="jkpopimage.close();">