TalkPHP
 
 
Account Login
Latest Articles
» The basic usage of PHPTAL, a XML/XHTML template library for PHP
» Vulnerable methods and the areas they are commonly trusted in.
» Simple way to protect a form from bot
» The Basics On: How Session Stealing Works
» How to keep your forms from double posting data
IRC Channel
IRC Speech Bubble Join the friendly bunch on IRC...
(#TalkPHP on Freenode)

...Also available via a web interface.

See this thread for information on the TalkPHP Free Hugs Initiative™. Subject to availability.
Associates
Associates
CSS Tutorials
Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old 03-07-2008, 10:39 PM   #1 (permalink)
The Acquainted
 
freenity's Avatar
 
Join Date: Feb 2008
Posts: 119
Thanks: 17
freenity is on a distinguished road
Default pop up box

Hi. I am making a test page to see how to make a pop up box (div) that will appear when a the cursor is over other div and disappear when it is not over this div. The appearing is quite easy, just made it with css, when the div2 is hover div1 should be visible.

But the problem is how to determine when the cursor is not over this div.
Of course it could be done with javascript: settinming a function for every 1 sec, to check the mouse position and calculate if it's over the div or not, but I think it's very bad method, I guess there should be something easier...
Any ideas?
__________________
http://feudal-times.net - My PBB Game
http://gwphp.feudal-times.net - My Blog "Gaming With PHP"
freenity is offline  
Reply With Quote
Old 03-07-2008, 10:43 PM   #2 (permalink)
The Addict
 
Join Date: Nov 2007
Posts: 264
Thanks: 2
TlcAndres is on a distinguished road
Default

<div onmouseover="javascript:alert('ello');"> boom! </div>

works
__________________
"What everyone seems to forget is that while knowledge certainly is something - it's the implementation of knowledge that brings power" - Andres Galindo.
TlcAndres is offline  
Reply With Quote
Old 03-07-2008, 10:45 PM   #3 (permalink)
The Acquainted
 
freenity's Avatar
 
Join Date: Feb 2008
Posts: 119
Thanks: 17
freenity is on a distinguished road
Default

no, I meant not alert...
something like a tooltip...
will look for an example and post it here if I find
__________________
http://feudal-times.net - My PBB Game
http://gwphp.feudal-times.net - My Blog "Gaming With PHP"
freenity is offline  
Reply With Quote
Old 03-07-2008, 10:46 PM   #4 (permalink)
The Acquainted
 
freenity's Avatar
 
Join Date: Feb 2008
Posts: 119
Thanks: 17
freenity is on a distinguished road
Default

DHTML JavaScript Tooltips

like this one, when you mouse your cursor over the photo.
A personalized div with html in it.. not an alert box
__________________
http://feudal-times.net - My PBB Game
http://gwphp.feudal-times.net - My Blog "Gaming With PHP"
freenity is offline  
Reply With Quote
Old 03-07-2008, 10:52 PM   #5 (permalink)
The Addict
 
Join Date: Nov 2007
Posts: 264
Thanks: 2
TlcAndres is on a distinguished road
Default

Oh - you also want to know the javascript neccesary to make the actual tooltipbox - I got you.

I'd check out DHTML JavaScript Tooltips

haha, beat me to it.
__________________
"What everyone seems to forget is that while knowledge certainly is something - it's the implementation of knowledge that brings power" - Andres Galindo.
TlcAndres is offline  
Reply With Quote
Old 03-08-2008, 07:03 PM   #6 (permalink)
The Acquainted
 
freenity's Avatar
 
Join Date: Feb 2008
Posts: 119
Thanks: 17
freenity is on a distinguished road
Default

ok, I guess some code is needed here:

PHP Code:
<style>

#btn1
{
    
width300px;
    
height50px;
    
positionabsolute;
    
top100px;
    
left50px;
    
background#eeeeee;
    
z-index22;
}

#popup
{
    
width200px;
    
height200px;
    
z-index999;
    
background#ee8888;
    
border1px solid #222222;
    
positionrelative;
    
top0px;
    
left0px;
    
visibilityhidden;
}

#btn1:hover #popup
{
    
visibilityvisible;
}

</
style


<
div id="btn1">
    <
div id="popup"></div>
</
div
so when you hover btn1, popup appears. So how do I hide it?? How do I know when the mouse is not over btn1???
__________________
http://feudal-times.net - My PBB Game
http://gwphp.feudal-times.net - My Blog "Gaming With PHP"
freenity is offline  
Reply With Quote
Old 03-08-2008, 09:15 PM   #7 (permalink)
The Contributor
 
DeMo's Avatar
 
Join Date: Jan 2008
Location: Brazil
Posts: 77
Thanks: 14
DeMo is on a distinguished road
Default

Why don't you use JavaScript? It's a lot easier...
HTML Code:
<script type="text/javascript">
function show() {
  document.getElementById("popup").style.display = "block";
}

function hide() {
  document.getElementById("popup").style.display = "none";
}
</script>


<div id="btn1" onmouseover="show()" onmouseout="hide()">
  <div id="popup">content</div>
</div>
Send a message via ICQ to DeMo Send a message via MSN to DeMo Send a message via Skype™ to DeMo
DeMo is offline  
Reply With Quote
The Following User Says Thank You to DeMo For This Useful Post:
freenity (03-09-2008)
Old 03-08-2008, 11:39 PM   #8 (permalink)
The Acquainted
 
Gareth's Avatar
 
Join Date: Jan 2008
Posts: 136
Thanks: 4
Gareth is on a distinguished road
Default

Another way, which is in my opinion nicer, is to use the jquery framework to produce tooltips.

Actually, I am going to write a tutorial / article on it now!

Gareth
Gareth is offline  
Reply With Quote
Old 03-09-2008, 07:29 AM   #9 (permalink)
The Wanderer
 
ubie's Avatar
 
Join Date: Mar 2008
Location: malang, Indonesia
Posts: 14
Thanks: 0
ubie is on a distinguished road
Default

try mootools tooltip .. ^__^
Send a message via Yahoo to ubie
ubie is offline  
Reply With Quote
Old 03-09-2008, 10:50 AM   #10 (permalink)
The Acquainted
 
freenity's Avatar
 
Join Date: Feb 2008
Posts: 119
Thanks: 17
freenity is on a distinguished road
Default

Quote:
Originally Posted by DeMo View Post
Why don't you use JavaScript? It's a lot easier...
HTML Code:
<script type="text/javascript">
function show() {
  document.getElementById("popup").style.display = "block";
}

function hide() {
  document.getElementById("popup").style.display = "none";
}
</script>


<div id="btn1" onmouseover="show()" onmouseout="hide()">
  <div id="popup">content</div>
</div>
thanks!
So there is no way to detect the mouseout event only with css??
__________________
http://feudal-times.net - My PBB Game
http://gwphp.feudal-times.net - My Blog "Gaming With PHP"
freenity is offline  
Reply With Quote
Old 03-09-2008, 07:58 PM   #11 (permalink)
The Contributor
 
DeMo's Avatar
 
Join Date: Jan 2008
Location: Brazil
Posts: 77
Thanks: 14
DeMo is on a distinguished road
Default

Quote:
So there is no way to detect the mouseout event only with css??
I guess not.
CSS is to be used only for styling, and not for showing/hiding other elements.
Send a message via ICQ to DeMo Send a message via MSN to DeMo Send a message via Skype™ to DeMo
DeMo is offline  
Reply With Quote
Old 03-10-2008, 04:40 AM   #12 (permalink)
Orc
The Prestige
 
Orc's Avatar
 
Join Date: Dec 2007
Posts: 1,044
Thanks: 193
Orc is on a distinguished road
Default

No, you can detect the mouse, heres some code to get the position:
Code:
function CursorPosition(e) 
{
	if (!e) e = window.event;
	
    var cursor = {x:0, y:0};
	
	if (!e)
	{
		return cursor;
	}
	
    if (e.pageX || e.pageY) {
        cursor.x = e.pageX;
        cursor.y = e.pageY;
    } 
    else {
        cursor.x = e.clientX + 
            (document.documentElement.scrollLeft || 
            document.body.scrollLeft) - 
            document.documentElement.clientLeft;
        cursor.y = e.clientY + 
            (document.documentElement.scrollTop || 
            document.body.scrollTop) - 
            document.documentElement.clientTop;
    }
    return cursor;
}

// Then you could do
function popup(e)
{

   var pos = CursorPosition(e);
   var popElem = document.getElementById('popup');
   popElem.style.display = "block";
   popElem.style.left = pos.x + '32';
   popElem.style.top = pos.y + '32';
}
__________________
VillageIdiot can have my babbies ;d
Orc is offline  
Reply With Quote
The Following User Says Thank You to Orc For This Useful Post:
freenity (03-10-2008)
Old 03-10-2008, 10:37 AM   #13 (permalink)
The Prestige
Upcoming Programmer Inquisitive 
 
Tanax's Avatar
 
Join Date: Sep 2007
Location: Sweden, Stockholm
Posts: 1,080
Thanks: 115
Tanax is on a distinguished road
Default

Check this out.

mootools demos - Tips

Really easy.
html Code:
<h3>Tips 1</h3>
<img src="/demos/MousewheelCustom/moo.png" alt="mooCow" class="Tips1" title="Tips Title :: This is my tip content" />

javascript Code:
var Tips1 = new Tips($$('.Tips1'));
__________________
Tanax is offline  
Reply With Quote
The Following User Says Thank You to Tanax For This Useful Post:
freenity (03-10-2008)
Old 03-10-2008, 10:49 AM   #14 (permalink)
The Acquainted
 
freenity's Avatar
 
Join Date: Feb 2008
Posts: 119
Thanks: 17
freenity is on a distinguished road
Default

Thanks.
I definitely have to learn some javascript library like mootools or jQuery :)
__________________
http://feudal-times.net - My PBB Game
http://gwphp.feudal-times.net - My Blog "Gaming With PHP"
freenity is offline  
Reply With Quote
Old 12-06-2008, 01:35 PM   #15 (permalink)
The Visitor
 
Join Date: Dec 2008
Posts: 2
Thanks: 0
kids0407 is on a distinguished road
Default

Quote:
Originally Posted by freenity View Post
ok, I guess some code is needed here:

PHP Code:
<style>

#btn1
{
    
width300px;
    
height50px;
    
positionabsolute;
    
top100px;
    
left50px;
    
background#eeeeee;
    
z-index22;
}

#popup
{
    
width200px;
    
height200px;
    
z-index999;
    
background#ee8888;
    
border1px solid #222222;
    
positionrelative;
    
top0px;
    
left0px;
    
visibilityhidden;
}

#btn1:hover #popup
{
    
visibilityvisible;
}

</
style


<
div id="btn1">
    <
div id="popup"></div>
</
div
so when you hover btn1, popup appears. So how do I hide it?? How do I know when the mouse is not over btn1???

this code not work at IE6+

Please help me , repair it
kids0407 is offline  
Reply With Quote
Old 12-06-2008, 02:26 PM   #16 (permalink)
La Vida es Sueño
Advanced Programmer Top Contributor 
 
Wildhoney's Avatar
 
Join Date: Sep 2007
Location: Oldham
Posts: 2,280
Thanks: 90
Wildhoney is on a distinguished road
Default

How about specifying the type? Does that help?

html4strict Code:
<style type="text/css">
__________________
The man who comes back through the Door in the Wall will never be quite the same as the man who went out.
Send a message via AIM to Wildhoney Send a message via MSN to Wildhoney Send a message via Yahoo to Wildhoney
Wildhoney is offline  
Reply With Quote
Old 12-06-2008, 03:26 PM   #17 (permalink)
The Visitor
 
Join Date: Dec 2008
Posts: 2
Thanks: 0
kids0407 is on a distinguished road
Default

FF that work
but IE 6, it not work
kids0407 is offline  
Reply With Quote
Old 12-06-2008, 04:28 PM   #18 (permalink)
The Prestige
Advanced Programmer Top Contributor Good Samaritan 
 
sketchMedia's Avatar
 
Join Date: Oct 2007
Location: Manchester, UK
Posts: 854
Thanks: 32
sketchMedia is on a distinguished road
Default

IE doesnt support :hover pseudo class on anything other than a link.
__________________
mysql> SELECT * FROM `users` WHERE `users`.`clue` > 0;
Empty set (0.00 sec)
sketchMedia is offline  
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


All times are GMT. The time now is 09:28 PM.

 
     

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0
Inactive Reminders By Icora Web Design