Getting started with JS instances

Source: Internet
Author: User

Question: http://topic.csdn.net/u/20081218/10/9b08d8f4-e2cc-4aff-93d9-fd57625cf568.html

Download this one.

Http://topic.csdn.net/u/ui/scripts/Csdn/Forum/UserOnline1.js

  1. <A href = "http://hi.csdn.net/jxyxhz" target = "_ blank" Title = "enter user personal space"> </a>
  1. <HTML xmlns = "http://www.w3.org/1999/xhtml">
  2. <Head>
  3. <Title> No title page </title>
  4. <SCRIPT type = "text/JavaScript">
  5. // Display Div
  6. Function outw (o)
  7. {
  8. VaR left, top;
  9. VaR OBJ = Document. getelementbyid ("out ")
  10. OBJ. style. Display = "Block ";
  11. VaR z = getxy (o); // here is an array.
  12. // The following function is to calculate the position of the display layer and determine based on the scroll bar.
  13. VaR H = obj. style. Height. Replace ('px ','');
  14. If (Z [1]-getlt (). Top)> H)
  15. {
  16. Top = Z [1]-H + 'px ';
  17. }
  18. Else
  19. {
  20. Top = Z [1] + 'px ';
  21. }
  22. VaR W = obj. style. Width. Replace ('px ','');
  23. VaR r = Document. Body. clientwidth-getlt (). Left-w-Z [0];
  24. // Alert (document. Body. clientwidth + 'Eee '+ getlt (). Left + 'ddd' + W + 'ccc '+ Z [0]);
  25. If (r> W)
  26. {
  27. Left = Z [0] + Z [2] + 'px ';
  28. }
  29. Else
  30. {
  31. Left = Z [0]-W + 'px ';
  32. }
  33. OBJ. style. Top = top;
  34. OBJ. style. Left = left;
  35. }
  36. // Get the scroll bar and pass away
  37. Function getlt ()
  38. {
  39. VaR top, left;
  40. Top=document.doc umentelement. scrolltop;
  41. Left+document.doc umentelement. scrollleft;
  42. Return {top: Top, left: Left}; // call method: getlt (). Top
  43. }
  44. // Obtain coordinates
  45. Function getxy (E)
  46. {
  47. L = E. offsetleft;
  48. T = E. offsettop;
  49. R = E. offsetright;
  50. B = E. offsetbottom;
  51. W = E. offsetwidth;
  52. H = E. offsetheight;
  53. While (EE = E. offsetparent) // cyclically calculates all parent layers and obtains the correct coordinates.
  54. {L + = E. offsetleft; t + = E. offsettop ;}
  55. Return [L, t, W, H] // returns an array.
  56. }
  57. // Hide
  58. Function fhidden (o)
  59. {
  60. Document. getelementbyid ("out"). style. Display = "NONE ";
  61. }
  62. </SCRIPT>
  63. </Head>
  64. <Body>
  65. <Div style = "height: 120px; width: 250px; text-align: center; position: absolute; left: 20px; top: 20px; display: none; Background: blue; "id =" out ">
  66. </Div>
  67. <Div style = "overflow: auto; width: 300px;">
  68. Learn JS
  69. <A href = "#" onmouseover = "outw (this)" onmouseout = "fhidden (this)"> technical features </a>
  70. Learn JS
  71. </Div>
  72. </Body>
  73. </Html>
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.