title: Positioning of Context menu
body: <p>I have developed a right click context menu in javascript for table .The position of context menu is at the down of cursor for every row of table.The final row of table is at end of the page,Now on right clicking the row the context menu is coming down but it should be shown up the cursor.Any help please </p>
  
  <pre><code>function ContextShow(event) {
  
  event = event || window.event;
  
  var m = getMousePosition(event);
  var s = getScrollPosition(event);
  var client_height = document.body.clientHeight;
  var display_context = document.getElementById('context_menu');
  
  if(replaceContext){
  
          display_context.style.display = "block";
          display_context.style.left = m.x + s.x +  "px";
          display_context.style.top =  m.y + s.y +  "px";
  
          replaceContext = false;
      }}
  
  
  function getMousePosition (e){
  e =   e || window.event;
  var position = {
      'x' : e.clientX,
      'y' : e.clientY
  }
  return position;}
  
  
  
  function getScrollPosition(){
  var x = 0;
  var y = 0;
  
  if( typeof( window.pageYOffset ) == 'number' ) {
      x = window.pageXOffset;
      y = window.pageYOffset;
  } else if( document.documentElement &amp;&amp; ( document.documentElement.scrollLeft || document.documentElement.scrollTop ) ) {
      x = document.documentElement.scrollLeft;
      y = document.documentElement.scrollTop;
  } else if( document.body &amp;&amp; ( document.body.scrollLeft || document.body.scrollTop ) ) {
      x = document.body.scrollLeft;
      y = document.body.scrollTop;
  }
  
  var position = {
      'x' : x,
      'y' : y
  }
  
  return position;
  </code></pre>
  
  <p>}</p>
  
  <p>Here, the contextShow will display the context menu of right click based on the mouse position using getMousePosition(event); and  getScrollPosition(event);</p>