¿Cómo puedo obtener la parte superior de la ventana del formulario de altura en mi punto de clic (una etiqueta) en la ventana usando css o jquery o php?

How can I get height form "window top" to "my click point on window" using css or jquery or php?

Hi, Problem is: I am displaying popup window on my web page screen but position of popup-window is going to change.I want to this center where I clicked. So I want to find out the height, but I'm unable to get height.

Please give me solution or any alternative of this.

Gracias por adelantado

preguntado el 09 de marzo de 12 a las 22:03

2 Respuestas

This is a short little jQuery-based script that moves an element to wherever the mouse was clicked:

$("body").click(function(event) {
    $("#box").css({top: event.pageY, left: event.pageX}).show();
});​

You can see it work here (along with the relevant HTML/CSS): http://jsfiddle.net/jfriend00/4p7xJ/

There are a number of different mouse coordinate positions in the event passed to the jQuery click handler. Among them are pageX, pageY, screenX, screenY, clientX and clientY. You can look each of these up in DND to see the detail description of each to decide which you want. If you're trying to position something relative to the clicked-on content (including scrolling position), then you probably want pageX and pageY like I used in my example.

respondido 09 mar '12, 23:03

@vin - Since you are new here on StackOverflow, do you realize that you are supposed to upvote answers that provided helpful information (click the up arrows to the left of the answer) and if you can identify a best answer that succeeds in answering your question, you should mark it as such by clicking the checkmark to the left of the answer. Both of these actions reward people who have spent time helping you (by giving them points on StackOverflow) and encourage them to answer other questions (of yours or of others) and help others who come along later see which answers are more helpful. - amigo00

Hi JFriend, i am trying to vote you but there is one message is displaying in popup box that: "Vote Up requires 15 reputation". right now my reputation is 1. plz let me know how to i can increase reputation. thank for this info. - vino

@vin - You get reputation points when people upvote your questions, when you mark an answer as accepted, when you answer a question and your answer gets upvoted or selected as the best answer. You will get some reputation points if you mark an answer as the best answer (by clicking on the checkmark to the left of the question). Yes, you do need some points before you can upvote, but you don't need points to mark a best answer. - amigo00

thanks, once I get 15 reputation I will vote to you, Thanks again. - vino

@vin - welcome to StackOverflow. You're off to a good start. - amigo00

First, make sure you have a valid doctype on your page, like HTML5 Doctype.

To get the height of the page, you can use a jquery function called height();

$(window).height();   // returns height of browser viewport
$(document).height(); // returns height of HTML document

Google "jquery height" to get more information.

You can also use some jquery plugins that do all the job for you, like

http://jquery.com/demo/thickbox/ y http://fancybox.net/

¡Que se diviertan!

Respondido 26 Oct 12, 13:10

No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas or haz tu propia pregunta.