/    Sign up×
Community /Pin to ProfileBookmark

About DIV tag

I have an image inside a DIV tag.When i click the mouse in a IE browser,at the particular position of mouse click,i need to display the DIV tag’s image.

I have captured the coordinates of the mouse click.
HOw to set the X,Y coordinates to the image i have taken inside the DIV tag using javascript.

to post a comment
JavaScript

1 Comments(s)

Copy linkTweet thisAlerts:
@tarsusOct 16.2006 — If I understand you correctly, you simply need to make sure that the div with your image is set to position:absolute; in your CSS, and that the div is located in the page's outermost container (so that, for example, 20px from the top of its containing element is the same as 20px from the top of the page).

Then, simply set the left and top CSS properties on mouse click:

[CODE]var mouseX= . . . ;
var mouseY= . . . ;

var the_div=document.getElementById('image_div');
the_div.style.left=mouseX + 'px';
the_div.style.top=mouseY + 'px';[/CODE]


And, of course, if your div is hidden until the mouse click, you will also need to reveal it after the left and top properties are set:

[CODE]the_div.style.display='block';[/CODE]
×

Success!

Help @sudidela spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.16,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...