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

  • Home
  • SEARCH
  • 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 714391
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T05:04:11+00:00 2026-05-14T05:04:11+00:00

I have a problem with an image preview that comes up when you hover

  • 0

I have a problem with an image preview that comes up when you hover over a thumbnail. I can change the distance between the preview and the cursor, but if a thumbnail is close to the side of the window, the preview cant fit and you only see part of it.. hope that makes sense…

is there a way to make it so that if the preview doesnt fit, it will show up on the other side of the cursor?….

Here is the script…

this.imagePreview = function() {
    /* CONFIG */
    xOffset = 10;
    yOffset = 30;
    // these 2 variable determine popup's distance from the cursor
    // you might want to adjust to get the right result
    /* END CONFIG */
    $("a.preview").hover(function(e) {
        this.t = this.title;
        this.title = "";
        var c = (this.t != "") ? "<br/>" + this.t : "";
        $("body").append("<p id='preview'>
  <img src='" + this.href + "' alt='Image preview' />" + c + "</p>");
        $("#preview")
            .css("top", (e.pageY - xOffset) + "px")
            .css("left", (e.pageX + yOffset) + "px")
            .fadeIn("slow");
    },
    function() {
        this.title = this.t;
        $("#preview").remove();
    });
    $("a.preview").mousemove(function(e) {
        $("#preview")
            .css("top", (e.pageY - xOffset) + "px")
            .css("left", (e.pageX + yOffset) + "px");
    });
};
// starting the script on page load
$(document).ready(function() {
    imagePreview();
});

EDIT:
see what i am getting,

http://img202.imageshack.us/img202/4991/browserpreviewf.jpg

my image at the right corner of the page so when i hover the img my preview goes even further right that is besides the page scrollbar half the preview is available…. How to get the preview to the left of the cursor..

  • 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-14T05:04:11+00:00Added an answer on May 14, 2026 at 5:04 am

    I would suggest using a tooltip plugin which does all the dirty positioning work for you. There are dozens available, I will show you how to do it with jQuery Tooltip.

    Provided that you have the following markup:

      <ul>
        <li><a href="bigimage.jpg"><img src="preview.jpg" /></a></li>
        <li><a href="big2.jpg"><img src="prev2.jpg" /></a></li>
      </ul>
    

    I think you get the idea (link to big image, preview image is the link). Then you could use the tooltip plugin as follows:

    $(document).ready(function() {
        $('img').tooltip({
            bodyHandler: function() {
                return $("<img/>").attr("src", $(this).parent().attr("href"));
            }
        });
    });
    

    (It has plenty of options which you all can test at the demo page).

    This may need some explanation. Every time a tooltip shall be displayed, the plugin executes the bodyHandler function. We use this function to generate the HTML the tooltip will conatin. So the magic that happens here is, that we extract the big image url from the hyperlink and create a new image with the same src on the fly. This image then gets displayed as the tooltip.

    Of course you could generate any (nested) HTML there, including titles, etc, but for the demonstration purpose, this should be enough.

    You can check out the result here!

    (All sytling you see is pure CSS, so don’t worry, you can adjust this to your requirements)

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

Sidebar

Ask A Question

Stats

  • Questions 457k
  • Answers 457k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer You need to setup the Alternate Access Mappings (AAM) correctly.… May 15, 2026 at 10:55 pm
  • Editorial Team
    Editorial Team added an answer In PHP 5.3 and up, there's the DateTime class. See… May 15, 2026 at 10:55 pm
  • Editorial Team
    Editorial Team added an answer We have a similar pattern where I'm working. Normally we… May 15, 2026 at 10:55 pm

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.