473,473 Members | 1,975 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Can't get onMouseOut to work...please help

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.he ight=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='+popheig ht+',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>'+windowtitl e+'</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();">

--
Gary Beard
Jan 13 '06 #1
4 1483
Gary <gbeard12@ said the following on 1/12/2006 11:36 PM:
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.he ight=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?
Looks like a whole lot of trouble to simply show a larger image.

<img src="small1.jpg"
onmouseover="document.images['bigImage'].src='big1.jpg'"....>

<img src="someBigImage.jpg" name="bigImage" .....>

You could add an onmouseout that swaps the big image back but I wouldn't
bother if it were me. If they mouseout, leave the current image until
they mouseover another image.
<snip>
<img src="/pics/oppsb.jpg" width="56" height="80"
onMouseover="jkpopimage('pics/oppsb.jpg', 250, 410, 'OPPSb'); return false"
onMouseout="jkpopimage.close();">


onmouseout="jkpopwin.close()"
--
Randy
comp.lang.javascript FAQ - http://jibbering.com/faq & newsgroup weekly
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
Answer:It destroys the order of the conversation
Question: Why?
Answer: Top-Posting.
Question: Whats the most annoying thing on Usenet?

Please quote what you are replying to.

If you want to post a followup via groups.google.com, don't use the
"Reply" link at the bottom of the article. Click on "show options" at
the top of the article, then click on the "Reply" at the bottom of the
article headers.

Jan 13 '06 #2
Randy,
Will this create a popup window or just enlarge the image where it's at?
Here's the problem I am having. I am using a script that enlarges the pic
where it's at, but the whole page has to redraw to allow for the larger
image (which doesn't look very good). So, I made a table and made the row
heights large enough to accept the larger version of the pic (I'm only using
one pic and showing a small pic on the web page and when they mouse over it,
it enlarges to the actual picture size). I like how my new script opens a
popup window and closes it onMouseout.
Does this

<img src="small1.jpg"
onmouseover="document.images['bigImage'].src='big1.jpg'"....>

<img src="someBigImage.jpg" name="bigImage" .....>

need 2 pics, one small and one large, or can the "small1.jpg" have to be a
different size than "someBigImage.jpg"? Also, I'm trying to get away from
having to number every occurance of the script. I sometimes need to add
images at the top of the page or in the middle of the page and it can get
rather tedious trying to locate what number I'm on.
With my new script, my server is adding text within the script which
interrupts the script, rendering it useless (the server obviously thinks the
lines

jkpopwin.document.write
('<html><title>'+windowtitle+'</title><body '+bodyattribute+'>
<img src="'+imgpath+'" style="margin-bottom:
0.5em"><br>'+textdescription+'</body></html>')
jkpopwin.document.close()

are referring to the BODY of the page and not realizing it is still in the
HEAD section). Is there a way around any of the problems I have referred to
in this message?
Thanks,
Gary Beard
Jan 16 '06 #3
Gary <gbeard12@ said the following on 1/15/2006 9:33 PM:
Randy,
Will this create a popup window or just enlarge the image where it's at?
Neither. It swaps a different image to show your big image.
Here's the problem I am having. I am using a script that enlarges the pic
where it's at, but the whole page has to redraw to allow for the larger
image (which doesn't look very good).


The code I gave won't do that. You would have one large image on the
page with thumbnails on the page. You mouseover the thumbnail and it
will put the large version of the thumbnail into the large image on the
page.
--
Randy
comp.lang.javascript FAQ - http://jibbering.com/faq & newsgroup weekly
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
Jan 16 '06 #4
Thanks for the reply Randy...I'll see what I can do with it.

--
Gary Beard
Jan 16 '06 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Paweł Gałecki | last post by:
How can I set a different border color for a table row? All I found in the MSDN for <TR> was: Scripting object.borderColor but it doesn't work for <TR> though it works for <TD>. I would like to...
1
by: Allen | last post by:
I am trying to add an additional photo/hyperlink to the company web site (I didn't create it) without any luck. The mouseover feature 'highlights' pics by swapping them with another pic using this...
3
by: bigoxygen | last post by:
Hi. I have a list that is similar to this: -Evaluation +test +test -Students +test I would like to change the "-" bullet only, but I cannot. My
13
by: LRW | last post by:
Having a problem getting a onSubmit function to work, to where it popsup a confirmation depending on which radiobutton is selected. Here's what I have: function checkdel() { if...
7
by: x muzuo | last post by:
Hi guys, I have got a prob of javascript form validation which just doesnt work with my ASP code. Can any one help me out please. Here is the code: {////<<head> <title>IIBO Submit Page</title>...
1
by: laurakr | last post by:
I am trying to use a clear to get my bottom nav bar below the quote box on the right, but it isn't working. I would like the bottom edge of the quote box to "stick" to the footer nav bar but copy...
2
by: Daz | last post by:
Hi everyone. I think my problem is a simple one, but I am completely baffled as to how to pull it off. I have a piece of code like so... document.write( "<img id=\"slideshow_toggle\"...
8
by: rajesh | last post by:
< script language = javascript c =...
4
by: zion4ever | last post by:
Hello good people, Please bear with me as this is my first post and I am relative new to ASP. I do have VB6 experience. I have a form which enables users within our company to do an intranet...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.