Ver Mensaje Individual
  #1 (permalink)  
Antiguo 18/05/2013, 17:08
Avatar de alberto510a
alberto510a
 
Fecha de Ingreso: abril-2013
Mensajes: 351
Antigüedad: 11 años
Puntos: 35
Exclamación e.pageX, e.pageY = desajuste en posición

Hola.

He creado un script de jQuery para que al clickar sobre un enlace genere un div justo en la posición del click más 15 px tanto en el eje x como en y.

Lo he probado en mi ordenador y funciona perfectamente pero el problema viene cuando lo subo a mi web, algún estilo css o algo le afecta y hace que salga más alejado de la cuenta y no consigo encontrar que es.

Este es mi script:

Código Javascript:
Ver original
  1. $(document).ready(function(){
  2.     a = 0;
  3.     $('#news').click(function(e){
  4.         $('#news2').html('');
  5.         $('#news2').animate({'width':'0px','height':'0px'},a,function(){
  6.         var x = e.pageX + 15;
  7.         var y = e.pageY + 15;
  8.         $('#news2').css({'border-radius':'15px','background-color':'#C63','position':'absolute','top':y,'left':x});
  9.         $('#news2').animate({'width':'210px','height':'140px'},600,function(){
  10.         $('#news2').html('<ul><li><a target="_blank" href="http://www.guardian.co.uk/">TheGuardian</a></li><li><a target="_blank" href="http://www.express.co.uk/">Express</a></li><li><a target="_blank" href="http://www.nytimes.com/">The New Your Times</a></li><li><a target="_blank" href="http://www.nypost.com/">New York Post</a></li><li><a target="_blank" href="http://europe.wsj.com">The Wall Street Journal</a></li></ul>');
  11.         a = 300;
  12.         });
  13.         });
  14.        
  15.     });
  16.     $('#news2').mouseleave(function(){
  17.         $('#news2').html('');
  18.         $('#news2').animate({'width':'0px','height':'0px'},a);
  19.     });
  20.  
  21.  
  22. });

Y esta mi página:

http://coolenglish.tk/index.php?option=com_content&view=featured&Itemid= 104

Saludos y gracias por leerme.