/    Sign up×
Community /Pin to ProfileBookmark

show full size image on mouseover

Hello

I was looking for a javascript code to show an image in full size on moueover, I use this script on the site

[CODE]function ShowPicture(id,Source) {
if (Source==”1″){
if (document.layers) document.layers[”+id+”].visibility = “show”
else if (document.all) document.all[”+id+”].style.visibility = “visible”
else if (document.getElementById) document.getElementById(”+id+”).style.visibility = “visible”
}
else
if (Source==”0″){
if (document.layers) document.layers[”+id+”].visibility = “hide”
else if (document.all) document.all[”+id+”].style.visibility = “hidden”
else if (document.getElementById) document.getElementById(”+id+”).style.visibility = “hidden”
}
} [/CODE]

CSS code i use:

[CODE]<style type=”text/css”>
#Style {
position:absolute;
visibility:hidden;
border:solid 1px #CCC;
padding:5px;

}
</style>[/CODE]

On the site to to body I put this html code:

[CODE]<a href=”#” onMouseOver=”ShowPicture(‘Style’,1)” onMouseOut=”ShowPicture(‘Style’,0)”>Click Here To Show Image</a>
<div id=”Style”><img src=”/sites/default/files/peroulades.jpg”></div>[/CODE]

When Im hovering over the link image is shown full size,

Problem: if you take a look: [url]http://www.online-dovolenka.sk/dovolenka_korfu[/url]

if hover over both links “Click Here To Show Image” you will see same image, but I put two different images? where is the problem? any ideas?

[CODE]<a href=”#” onMouseOver=”ShowPicture(‘Style’,1)” onMouseOut=”ShowPicture(‘Style’,0)”>Click Here To Show Image</a>
<div id=”Style”><img src=”/sites/default/files/peroulades.jpg”></div>

<a href=”#” onMouseOver=”ShowPicture(‘Style’,1)” onMouseOut=”ShowPicture(‘Style’,0)”>Click Here To Show Image</a>
<div id=”Style”><img src=”/sites/default/files/pantokrator.jpg”></div> [/CODE]

to post a comment
JavaScript

1 Comments(s)

Copy linkTweet thisAlerts:
@rtretheweyMar 21.2012 — Your code was a bit long for me to play with just at the moment, but I do have a suggestion. In your top example, your code checks 'document.layers'. 'document.layers' was exclusive to Netscape 4, which was replaced by Netscape 6 in 2000 and no longer exists. Similarly, 'document.all' being available but not 'document.getElementById' was exclusive to Internet Explorer 4, which also no longer exists. Your code could be simplified to only checking:

document.getElementById(xx).style.visibility

for all browsers in use today and might help you find the problem. Good luck!
×

Success!

Help @joekoo spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.8,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...