Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7002719
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T20:57:53+00:00 2026-05-27T20:57:53+00:00

I currently am using a simple javascript code to get a popup of data

  • 0

I currently am using a simple javascript code to get a popup of data to appear when you click a hyperlink of a table.

However, I am unable to have the popup appear near the link whatsoever. Does anyone have any suggestions or better versions of scripts that can perform this action? jQuery is an option as well.
Thanks, here is my current javascript code:

function createPopup(x, y, divID) {
    var p = document.getElementById(divID);
    p.style.display="block";
    p.style.Left = x;
    p.style.Top = y;
    document.body.appendChild(divID);
}

And this is the css

.popup {
    background-color: #FFFFFF;
    border: thin solid #000000;
    color: black;
    display: none;
    font-size: 11px;
    height: auto;
    padding: 10px;
    position: absolute;
    width: 300px;
}

This is the link I use to popup the div.

<a id=buttonRed href="javascript:createPopup(\'-40px\', \'' . (-15 + ($resultCounter * 10)) . 'px\', \'Name' . $id . '\');">

As you can see the data is dynamic as I am pulling the data dynamically.

The popup works well other than the fact that the popup does not appear near the hyperlink.

Suggestions?

UPDATED CODE::

    <script>
    window.onload = init;
    function init() {
        if (window.Event) {
            document.captureEvents(Event.MOUSEMOVE);
        }
        document.onmousemove = getCursorXY;
    }

    function getCursorXY(e) {
        document.getElementById('cursorX').value = (window.Event) ? e.pageX : event.clientX + (document.documentElement.scrollLeft ? document.documentElement.scrollLeft : document.body.scrollLeft);
        document.getElementById('cursorY').value = (window.Event) ? e.pageY : event.clientY + (document.documentElement.scrollTop ? document.documentElement.scrollTop : document.body.scrollTop);
    }

    function createPopup(divID) {
        var p = document.getElementById(divID);
        p.style.display="block";
        p.style.Left = (window.Event) ? e.pageX : event.clientX + (document.documentElement.scrollLeft ? document.documentElement.scrollLeft : document.body.scrollLeft);;
        p.style.Top = (window.Event) ? e.pageY : event.clientY + (document.documentElement.scrollTop ? document.documentElement.scrollTop : document.body.scrollTop);;
        document.body.appendChild(divID);
    }
</script>

This is what I have for the javascript but it is still not loading at the correct location.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T20:57:53+00:00Added an answer on May 27, 2026 at 8:57 pm

    If you can use JQuery instead then you can just grab the offset of the clicked link and add it to the css of the popup. Something like this:

    $("#buttonRed").click(function (e) {
        var offset = $(this).offset();
        var topOffset = 35;
        $(".popup").css('left',offset.left);    
        $(".popup").css('top',offset.top - topOffset);
        $(".popup").css('display','block');
    });
    

    The topOffset variable determines how much higher it should be with regards to the clicked link. You can also add a leftOffset variable as well obviously. I have set up an example here: http://jsfiddle.net/mn6rg/

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have simple JavaScript code that is using the Ajax API for fetching a
I'm currently developing a simple iPhone application using a UITabBar and table views for
Im currently using a simple javascript redirect (called on load) with a delay to
Our company is currently using a simple trunk/release/hotfixes branching model and would like advice
I am currently running a simple EJB application using a stateless Session Bean. I
Using pyUnit to do what is currently a very small and simple unit test
I am currently working on a simple web application through Google App engine using
Currently using System.Web.UI.WebControls.FileUpload wrapped in our own control. We have licenses for Telerik. I
Currently I have a simple form with a plus and minus on it and
I am currently having difficulty using the Google weather API in JavaScript using Mootools.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.