473,322 Members | 1,540 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,322 software developers and data experts.

Div display on same position where mouse clicked but window focus go on top

gskoli
23
Dear all ,
I am giving you snippet of the code , where i have taken div which is i have put above the row of one table and[br] on mouse click changing the position of the div and showing it as per the x-y coordinate but every time suppose i have scroll the it again goes to to top...[br]

Expand|Select|Wrap|Line Numbers
  1.         function setVisible(t,e,obj)
  2.         {
  3.                 if(e || t){
  4.                         var posx = 0; var posy = 0;
  5.                         if (!e){var e = window.event;}
  6.                         if (e.pageX || e.pageY){alert('ONe');
  7.                                 posx = e.pageX;
  8.                                 posy = e.pageY;
  9.                                 //if(document.body.scrollTop){
  10.                                 //      posy = posy + document.body.scrollTop;
  11.                                 //}
  12.                         }
  13.                         else if (e.clientX || e.clientY){ alert('TwO'); //for IE
  14.                                 posx = e.clientX;
  15.                                 posy = e.clientY;
  16.                                 if(document.body.scrollTop){
  17.                                         posy = posy + document.body.scrollTop;
  18.                                 }
  19.  
  20.                         } //alert(posx+'::'+posy);
  21.                         //document.getElementById(obj).style.cursor = "hand";
  22.                         alert(document.body.scrollTop);
  23.                         document.getElementById(obj).style.left = posx+'px';
  24.                         document.getElementById(obj).style.top = posy+'px';
  25.                 }
  26.                 var obj = document.getElementById(obj); alert(obj.style.display+'HHHHHH'+ obj.style.left+'###'+ obj.style.top);
  27.                 obj.style.display = (obj.style.display == 'block') ? 'none' : 'block';
  28.         }
  29.  
  30. <body >
  31.   <table>
  32. <tr>
  33.  
  34. </tr>
  35. <div id='layer1'>
  36. </div>
  37. // Some loop to print rows
  38. <tr>
  39.   <a href= '#' onclick="setVisible(this,event,'layer1');" >Bunti </a>
  40. </tr>
  41. //loop over  
  42.  </table>
  43. </body >
  44.  
Please help me out
Aug 16 '10 #1
0 1163

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Fred Snider | last post by:
Help! Opening a new window using the window.open( ) command works great for opening new windows and having them on top and having the focus. The window.focus command brings any existing...
1
by: CES | last post by:
All, I'm trying to test if a browser is configured so that I can use popup windows or if it has a popup blocker installed... the only solution I was able to think of, was one that would pop up a...
5
by: Wei | last post by:
I need the current window stay on focus. The user will have to click on exit button to exit the window. How can I do this in asp.net in C#? Thank you
2
by: Wei | last post by:
I need the current window stay on focus. The user will have to click on exit button to exit the window. When I use the following code, I got an error: "Not implemented" Code: private void...
3
by: Frances | last post by:
this is for a browser window that contains a chat app that is an applet... when browser window is not in focus I would like users to somehow get notified when a message arrives, more or less like...
4
by: Roger | last post by:
Hi, I am confused about the differences between this.window.focus(), window.focus(), and this.focus(). I want to use the calls in a <body onload="..."tag. What are the differences between...
4
by: Jason | last post by:
Hi, Here's the scenario: I have a web application that has window A and window B. A user has both window A and B open - window A is in the foreground and window B is behind it. If the...
1
idsanjeev
by: idsanjeev | last post by:
<%@ Language =vbscript%> <% Option Explicit %> <html> <head><TITLE>VOICE OF BARAUNIANS</TITLE></head> <body> <!--#include file="front.inc"--> <div style="Position:Absolute; width:700; TOP:0;...
3
by: acehigh1983 | last post by:
Is it possible to focus a window in firefox and safari?? i have a webpage that opens another window, it then focuses on the original window (the new window that opened now behind it in the...
4
by: Spizzat2 | last post by:
I'm trying to figure out a workaround to a minor annoyance that I'm coming up with while coding a site. I've got some keyboard shortcuts set up for the site via javascript, and when I press escape,...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.