Click here to Skip to main content
15,881,803 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
HTML
<script type="text/javascript">
function winopen(e,linkid)
{
   if(document.all)
   {
   leftpos=event.screenX; 
   toppos=event.screenY;
   }
   if(document.layers||document.getElementById)
   {
   leftpos=e.screenX;
   toppos=e.screenY;
   }
   toppos=toppos+10
      MessageWin=eval('window.open(linkid,"newwin",config="width=200,height=100,location=no,status=no,directories=no,toolbar=no,scrollbars=no,menubar=no,resiza ble=no,top='+toppos+',left='+leftpos+'")');
   MessageWin.focus()
}
</script>

<a href="#" onMouseOver="winopen(event,'Default2.aspx')"  önMouseOut="MessageWin.close()">Open Window</a>


here is my code to open a new window on mouse over and close the windows when mouse out. it working fine at google chrome, but have 1 small problem with IE with windows 7.

if the new windows open at the center of my mouse cursor, the browser read it as 'onMouseOut', so what happend here is the new windows keep open and close. how to solve this?
=================================================================
Added

JavaScript
var time;

function chkFocus(){

   time = setTimeout(function(){

if(MessageWin.onfocus){

}

else{

   MessageWin.close();

}

}, 100);

and set my onmouseover="chkFocus()";
well, problem still the same, i believe we almost solve the problem. i put timeout as '100' because i want it to be closed instantely when mouseout.
Posted
Updated 13-Nov-12 22:14pm
v2
Comments
Pro Idiot 14-Nov-12 2:49am    
"here is my code to open a new window on mouse over and close the windows when mouse out. it working fine at google chrome, but have 1 small problem with IE with windows 7.
"


In chrome , the window keeps opened, does not close on mouse out !
melvintcs 14-Nov-12 2:53am    
check ur first "o" at onMouseOut...
Pro Idiot 14-Nov-12 3:07am    
yes, got it , Now it is working fine for me on Chrome and IE-8
the new window is closing on mouseout , perfectly fine !
Pro Idiot 14-Nov-12 3:12am    
or you can change the value
toppos=toppos+10

10 to 20/30 as per your requirement , so the new window will never overlap on the mouse
melvintcs 14-Nov-12 3:19am    
i having the problem is the link is at the bottom right.

You can use:
http://jqueryui.com/dialog/[^]
Set position of dialog to someplace not over your link and close dialog on mouseout.

Or maybe tooltip? It seems nice for hovering over link.
http://jqueryui.com/tooltip/#tracking[^]

I am not sure what you want to show in those windows. If you want show some info about website from link maybe this will help you?
http://www.thumbalizr.com/apitools.php[^]
It's creates some nice thumbs of websites. Should work great with tooltip and you could cache those images.

I founding jQuery UI somewhat slow so you could investigate some other libraries or even roll out something on your own.

Check dojo to:
http://livedocs.dojotoolkit.org/dijit/Dialog[^]
http://dojotoolkit.org/reference-guide/1.8/dijit/Tooltip.html[^]

I bet it is even slower then jQuery. But it is even prettier then jQuery UI :)
 
Share this answer
 
Comments
melvintcs 14-Nov-12 22:07pm    
thx, ur links might help others, but i come with my own solution :)
n.podbielski 15-Nov-12 2:03am    
Great.
this is how i solve it:
JavaScript
var scrWidth = window.screen.width;
var scrheight = window.screen.height;

var widthPercent = event.screenX / scrWidth * 100
var heightPercent = event.screenY / scrHeight * 100

if(document.all){
   leftpos=event.screenX; 
   toppos=event.screenY;
}

if(document.layers||document.getElementById){
   leftpos=e.screenX;
   toppos=e.screenY;
}

toppos=toppos+10

if(widthPercent > 70){
   leftpos = leftpos * 0.7
}

if(heightPercent > 70){
   toppos = toppos * 0.7
}


by doing this, the new windows will appear at left hand side if my cursor is at the bottom right. simple but efficient :)
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900