javascript onmouseover show small windows then hide

Mobile
feeds
Welcome Login | Register

javascript onmouseover show small windows then hide
Reply Your Comments:
Click this button if you are interested in replying to this topic and leave your comments
Sent To Friend
CLick this button if you want to send this page to a friend.
Subsribe To Rss Feeds
Subscribe to RSS
CLick this button if you want to subscribe to this RSS Feed. You can use your browsers feeds burners if you have mozilla or internet explorer 7 or higher and keep up with updates.
  Forums Index
      » Javascipt Forums
        » » javascript onmouseover show small windows then hide
javascript onmouseover show small windows then hide
Post Description: man today i wanted to create a small javascript where if the user put their mouse arrow on an image, i want it to show a little popup window to show a message, but i didnt want an alert, i wanted a div included with css Javascipt
Post Tags:
This Post Has Been Viewed 1447 Times Since Fri Nov 07, 2008 2:04 pm Author hostman with 15 replies
javascript onmouseover show small windows then hide
Advertise On This Page




man today i wanted to create a small javascript where if the user put their mouse arrow on an image, i want it to show a little popup window to show a message, but i didnt want an alert, i wanted a div included with css. so this is the only thing i could come up with, i hope this helps you.

if you want to see it in action, just put your mouse over the little question mark image below. hopefully that works for you. if you have a better script please tell me

here is the code i use to make this happen:

Javascript Code:
here is the code:
<div class="code"><script type="text/javascript">
function ShowText(id) {
document.getElementById(id).style.display = 'block';
}
function HideText(id) {
document.getElementById(id).style.display = 'none';
}

</script>

<style type="text/css">
<!--
.box {
background-color: #504D6F;
border: 1px solid #FFF;
height: 100px;
width: 200px;
padding: 5px;
}
-->
</style>

<span onmouseover="ShowText('answer1'); return false;" >
<img src="http://www.wallpaperama.com/forums/post-images/20081107_6718_question-mark.gif"></span>
<span id="answer1" class="box" onMouseOut="HideText('answer1'); return false;" style="display:none">You can find good wallpapers at wallpaperama.com plus stuff to get your wallpaper website going</span></p> </div>

DEMO

Put your mouse on this little image:





Leave Your Comments

Your Name
Your Email Address (Will Not Be Published)
Notify Me When Someone Replies to this Page
(An email will be sent to you when someone replies to your comments)
Your Comments
Include A Picture with your comments
Share
| More
Share this page by putting this URL in your comments to other websites like myspace, Facebook, Twitter friendster, Hi5, Groups, Boards, Forum or others. Just Copy and Paste this Code
URL:
To embed this topic, just copy the code from the "Embed" box. Once you've copied the code, just paste it into your website or blog to embed it.
Embed:
BBCODE is use on forums. You can put this code on all your BBCODE enabled forums like PhpBB, vBulletin® and others. Just Copy and Paste this code on your Posts and Replies on your forums
BBCODE:
Subscribe Feeds
Webmasters - Exchange Links With Us. Add related websites to this topic
Add Link:
Links Related to : javascript onmouseover show small windows then hide

Comments and replies About javascript onmouseover show small windows then hide
:: 1 :: Reply #79867 Reply By hostman On Fri Nov 07, 2008 2:18 pm
hostman:
i realize that there might be some beginners reading my tutorial here so just incase there is someone who has no idea how to make this code run i will tell you the steps ok.

1. open your favorite text editor. i am using window xp so i will use notepad.exe - you can find notepad but going to the Start > Programs >> Accessories

2. copy and paste the Javascript Code into your text editor

3. save the file as "wallpaperama.html" in "My Documents" Folder

4. now go to your "My Documents" folder and open "wallpaperama.html" with your broswer.- or simply just double click on the document. then it will open with internet explorer and boom, you will see the script in action
:: 2 :: Reply #79869 Reply By ajax On Fri Nov 07, 2008 2:22 pm
ajax:
i have a better solution for you:

check out my example, just put your mouse over the question mark image:

You can find good wallpapers at wallpaperama.com plus stuff to get your wallpaper website going


:: 3 :: Reply #79870 Reply By ajax On Fri Nov 07, 2008 2:23 pm
ajax:
and here is the code:
<style type="text/css">
<!--
.box {
background-color: #F4F4F4;
border: 1px solid #CCC;
height: 100px;
width: 200px;
padding: 5px;
display:none;
position:absolute;
}

-->
</style>
<script type="text/javascript" language="JavaScript">
var cX = 0; var cY = 0; var rX = 0; var rY = 0;
function UpdateCursorPosition(e){ cX = e.pageX; cY = e.pageY;}
function UpdateCursorPositionDocAll(e){ cX = event.clientX; cY = event.clientY;}
if(document.all) { document.onmousemove = UpdateCursorPositionDocAll; }
else { document.onmousemove = UpdateCursorPosition; }
function AssignPosition(d) {
if(self.pageYOffset) {
rX = self.pageXOffset;
rY = self.pageYOffset;
}
else if(document.documentElement && document.documentElement.scrollTop) {
rX = document.documentElement.scrollLeft;
rY = document.documentElement.scrollTop;
}
else if(document.body) {
rX = document.body.scrollLeft;
rY = document.body.scrollTop;
}
if(document.all) {
cX += rX;
cY += rY;
}
d.style.left = (cX+10) + "px";
d.style.top = (cY+10) + "px";
}
function HideText(d) {
if(d.length < 1) { return; }
document.getElementById(d).style.display = "none";
}
function ShowText(d) {
if(d.length < 1) { return; }
var dd = document.getElementById(d);
AssignPosition(dd);
dd.style.display = "block";
}
function ReverseContentDisplay(d) {
if(d.length < 1) { return; }
var dd = document.getElementById(d);
AssignPosition(dd);
if(dd.style.display == "none") { dd.style.display = "block"; }
else { dd.style.display = "none"; }
}
//-->
</script>


<span
onmouseover="ShowText('Message'); return true;"
onmouseout="HideText('Message'); return true;"
href="javascript:ShowText('Message')">
<img src="http://www.wallpaperama.com/forums/post-images/20081107_6718_question-mark.gif">
</span>
<div
id="Message"
class="box"
>
You can find good wallpapers at wallpaperama.com plus stuff to get your wallpaper website going
</div>
:: 4 :: Reply #79871 Reply By hostman On Fri Nov 07, 2008 2:36 pm
hostman:
oh wow, that's a much better javacript snippet showing exactly what i wanted to do. i wanted to create a javascript tutorial onmouseover to appear and hide when the onMouseOver Image Effect but is that your javascript Tutorial is much better and clearn. i see its more complicated but it works better. i like to have JavaScript to Show hide menu on this tutorial. but i guess thats another guide. i hope someone else also learns from your javascript Show/Hide Elements with JavaScript tutorial. i like the steps by steps where you show all the Javascript Links and Buttons Mouseover and Rollover Effect i really like those. next i hope to have a javascript Image swap on mouse over and mouse out. that would bee a neat trick to pull out. but i think you are going to have to usee css and Div tag to display and hide on mouse over. thanks for Tutorial Sharing this Site i like working with Javascript mouseover text windows examples and hopefully you can learn from me. im also working annother onmouseover display a box that show text URL that one i will post as soon as i am done it will also Show floating div near cursor on mouseover hide on mouseout which is similar to this one. i found this on the search engine http://www.tutorialtastic.co.uk/tutorial/showhide_elements_with_javascript maybe you can go to them and ask them if they have mroe

:: 5 :: Reply #84219 Reply By Keith On Sun Nov 30, 2008 11:38 pm
Keith:
exactly what i was looking for. thanks.

now i hope to be able to get it to work in my page for me.

time (and experimentation) will tell!

k.
:: 6 :: Reply #85740 Reply By Avijit On Thu Dec 11, 2008 5:03 am
Avijit:
this action is realy helpful to me.thank you.
then to i am looking for mouseover action in layer which can carry a transparent image over the main background.can u help me.
for a reference u can study templatemonster homepage(top)
:: 7 :: Reply #85855 Reply By Nitin On Thu Dec 11, 2008 11:06 pm
Nitin:
yes i got it

so many thanx to u..........
:: 8 :: Reply #86900 Reply By amit On Sat Dec 20, 2008 5:43 am
amit:
i tried quite a few hours to do the same but i couldn't succeed. when i used this code the it was perfectly fine and result success.thank you
:: 9 :: Reply #87460 Reply By jobed On Wed Dec 24, 2008 11:07 am
jobed:
me beginner.can tell more detail?
:: 10 :: Reply #89174 Reply By karen On Wed Jan 07, 2009 4:09 pm
karen:
i used this code, very nice. how to i tell it where to pop up the window? i attached it to a larger image, but i want it to pop up to the left and below the image and it sort of pops up all over the place to the right of the image.
thanks.
:: 11 :: Reply #91656 Reply By pankaj On Tue Jan 27, 2009 3:35 am
pankaj:
very good grafic
:: 12 :: Reply #93571 Reply By surendra On Wed Feb 11, 2009 7:16 am
surendra:
11-6718-1212895253.gif
this is awesome this is really useful thanks alot
:: 13 :: Reply #94926 Reply By Newbie^^ On Tue Feb 24, 2009 5:04 am
Newbie^^:
how do we place many like that? i tried to put two but it showed same details how would i place many? without the same details inside? help please...
:: 14 :: Reply #121116 Reply By Ashit On Sat Nov 21, 2009 10:30 am
Ashit:
21-6718-2005.jpg
interesting script. i found the original code behaves somewhat erratically - on mouseout the popup window does not disappear easily or often. i found that by changing the image to: <img src=""> mouseover </span> i get the text instead of the question mark. as such, the code could be used for text as well.
the ajax code works more smoothly, but the window remains blank (without the message)! some minor error remains that i have not been able to rectify (i am an interested novice & do not know javascript).
will appreciate help by direct e-mail.
as**t sarkar - bangalore nov 22, 2009
sarkarsweet at google dot com
:: 15 :: Reply #126956 Reply By surya On Fri Jan 29, 2010 2:10 am
surya:
it look's great ..very helpful thanks a lot.......