Foros del Web » Programando para Internet » Javascript »

Errores en Internet Explorer

Estas en el tema de Errores en Internet Explorer en el foro de Javascript en Foros del Web. Saludos a quien me pueda socorrer.... Esto parece una pesadilla, estoy programando una web que tiene unos cuantos efectos en Jquery, y desde ya que ...
  #1 (permalink)  
Antiguo 16/07/2009, 08:58
 
Fecha de Ingreso: mayo-2009
Mensajes: 20
Antigüedad: 15 años
Puntos: 0
Pregunta Errores en Internet Explorer

Saludos a quien me pueda socorrer....

Esto parece una pesadilla, estoy programando una web que tiene unos cuantos efectos en Jquery, y desde ya que en Firefox veo todo como corresponde; pero en Internet Explorer (de pronunciarlo me pone mal ya jajja) me tira los siguientes errores:

Cita:
Linea:45
Car: 117
Se esperaba un identificador una cadena o un numero

Linea:148
Car: 2
Se requiere un objeto
Segun el Firebug (pq Ie no me indica con exactitud dnd esta el error), seria en el archivo thw.js (plugin que realiza un scroll animado de manera horizontal) en la linea 147:

Código:
function addEvent( obj, type, fn ) {
147 if (obj.addEventListener)
148 obj.addEventListener( type, fn, false );
149 else if (obj.attachEvent) {
150 obj["e"+type+fn] = fn;
151 obj[type+fn] = function() { obj["e"+type+fn]( window.event ); }
152 obj.attachEvent( "on"+type, obj[type+fn] );
153 }
154}
Otro error con Firebug no encuentro.

Estos errores en Iexplorer, me bloquean otros efectos que tengo sobre un menu, y un efecto con FancyBox (ventanas tipo modal), entre otros...

La direccion de la web que estoy creando es: expresa.net78.net/ctln

Agradeceria una mano, me vuelvo loco, y no entiendo mucho de JavaScript...
  #2 (permalink)  
Antiguo 16/07/2009, 13:41
Avatar de djaevi  
Fecha de Ingreso: marzo-2007
Ubicación: Moreno, Buenos Aires
Mensajes: 400
Antigüedad: 17 años, 1 mes
Puntos: 47
Respuesta: Errores en Internet Explorer

Creo que podria ser porque en el if de la linea 147 no estas abriendo llaves:

147 if (obj.addEventListener)
148 obj.addEventListener( type, fn, false );
149 else if (obj.attachEvent) {

deberia ser asi

147 if (obj.addEventListener) {
148 obj.addEventListener( type, fn, false );
149 }else if (obj.attachEvent) {

y creo que tambien te esta sobrando una llave de cierre al final revisa eso otra cosa no veo que pueda ser, aunque es raro que con este tipo de error te funcione en mozilla.

Saludos
  #3 (permalink)  
Antiguo 17/07/2009, 09:50
 
Fecha de Ingreso: mayo-2009
Mensajes: 20
Antigüedad: 15 años
Puntos: 0
Respuesta: Errores en Internet Explorer

mmmm... copio una linea mas arriba, porque me parece que hay una llave antes que abre:

Código:
function addEvent( obj, type, fn ) {
	if (obj.addEventListener)
		obj.addEventListener( type, fn, false );
	else if (obj.attachEvent) {
		obj["e"+type+fn] = fn;
		obj[type+fn] = function() { obj["e"+type+fn]( window.event ); }
		obj.attachEvent( "on"+type, obj[type+fn] );
	}
}

Es raro este error, pued ser porque tengo algunos plugins mas de jQuery, pero no creo que tubiese que tener tantos problemas... en ie... directamente se anulan algunos efectos...

La web que estoy probando es: expresa.net78.net/ctrln
Gracias desde ya!
  #4 (permalink)  
Antiguo 17/07/2009, 15:18
Avatar de djaevi  
Fecha de Ingreso: marzo-2007
Ubicación: Moreno, Buenos Aires
Mensajes: 400
Antigüedad: 17 años, 1 mes
Puntos: 47
Respuesta: Errores en Internet Explorer

yo no digo llave de la funcion digo que no abris llave en el if...

if (obj.addEventListener)

deberia ser

if (obj.addEventListener) {

...

y }else if (...) {

...

}
  #5 (permalink)  
Antiguo 18/07/2009, 14:10
 
Fecha de Ingreso: mayo-2009
Mensajes: 20
Antigüedad: 15 años
Puntos: 0
Respuesta: Errores en Internet Explorer

djaevi, probe con lo que me dijiste, y asi y todo, me da error en la misma linea...
(Quite cualquier otro plugin por las dudas)

Te muestro el codigo entero del plugin a ver que sucede

Código:
window.onload = function() {
	HtinyScrolling.init(); scrollTips.init();
}

function gotoit(target){
	HtinyScrolling.scrollToIt(target);
}

var HtinyScrolling = {
	speed : 35,      //set here the scroll speed: when this value increase, the speed decrease. 
	maxStep: 150,	 //set here the "uniform motion" step for long distances
	brakeK: 3,		 //set here the coefficient of slowing down
	hash:null,		
	currentBlock:null,
	requestedX:0,
	init: function() {
		var lnks = document.getElementsByTagName('a');   
		for(var i = 0, lnk; lnk = lnks[i]; i++) {   
			if ((lnk.href && lnk.href.indexOf('#') != -1) &&  ( (lnk.pathname == location.pathname) ||
			('/'+lnk.pathname == location.pathname) ) && (lnk.search == location.search)) {  
			addEvent(lnk,'click',HtinyScrolling.initScroll,false);
			lnk.onclick=function(){return false;} // Safari
			}   
		}    
	},
	getTarget: function(target) {
		while(target.tagName.toLowerCase() != 'a')
			target = target.parentNode;
		return target;
	},
	getElementXpos: function(el){
		var x = 0;
		while(el.offsetParent){  
			x += el.offsetLeft;    
			el = el.offsetParent;
		}	return x;
	},		
	getScrollLeft: function(){
		if(document.all) return (document.documentElement.scrollLeft) ? document.documentElement.scrollLeft : document.body.scrollLeft;
		else return window.pageXOffset;   
	},	
	getWindowWidth: function(){
		if (window.innerWidth)	return window.innerWidth; 
		if(document.documentElement && document.documentElement.clientWidth) return document.documentElement.clientWidth;
	},
	getDocumentWidth: function(){
		if (document.width) return document.width;
		if(document.body.offsetWidth) return document.body.offsetWidth;
	},
	initScroll: function(e){
		var targ;  
		if (!e) var e = window.event;
		if (e.target) targ = e.target;
		else if (e.srcElement) targ = e.srcElement;  
		targ = HtinyScrolling.getTarget(targ);  //a fix by Skid X
		HtinyScrolling.hash = targ.href.substr(targ.href.indexOf('#')+1,targ.href.length); 
		HtinyScrolling.currentBlock = document.getElementById(HtinyScrolling.hash);   
		if(!HtinyScrolling.currentBlock) return;
		HtinyScrolling.requestedX = HtinyScrolling.getElementXpos(HtinyScrolling.currentBlock); 
		HtinyScrolling.scroll(targ); 
		return false;
	},
	scrollToIt: function(targ){ //thanks to Michael Ionita-Ganea
		target = document.getElementById(targ);
		HtinyScrolling.currentBlock = document.getElementById(targ);
		if(!HtinyScrolling.currentBlock) return;
		HtinyScrolling.requestedX = HtinyScrolling.getElementXpos(HtinyScrolling.currentBlock);
		HtinyScrolling.scroll(target);
		return false;
		
	}, 
	scroll: function(targ) {
		var left  = HtinyScrolling.getScrollLeft();
		if(HtinyScrolling.requestedX > left) { //a fix by Michael Ionita-Ganea
			var endDistance = Math.round((HtinyScrolling.getDocumentWidth() - (left + HtinyScrolling.getWindowWidth())) / HtinyScrolling.brakeK);
			endDistance = Math.min(Math.round((HtinyScrolling.requestedX-left)/ HtinyScrolling.brakeK), endDistance);
			var offset = Math.min(Math.abs(Math.round((HtinyScrolling.requestedX-left)/ HtinyScrolling.brakeK)), HtinyScrolling.maxStep);
		}else {
				var offset = - Math.min(Math.abs(Math.round((HtinyScrolling.requestedX-left)/ HtinyScrolling.brakeK)), HtinyScrolling.maxStep);
		} 
		window.scrollTo(left + offset, 0);
		if(Math.abs(left-HtinyScrolling.requestedX) <= 1 || HtinyScrolling.getScrollLeft() == left) {
			HtinyScrolling.hash = null;
		} else 	setTimeout(HtinyScrolling.scroll,HtinyScrolling.speed);
	}
}

 
var scrollTips = {
	dx : null,
	init : function() {	
		if (window.addEventListener) {
		window.addEventListener("DOMMouseScroll", this.mouseScroll, false);
		} else document.attachEvent("onmousewheel", this.mouseScroll); 
		var left = document.getElementById('left');
		addEvent(left,'mouseover', function() {this.dx=setInterval('scrollTips.arrowScroll(0)',100);return false;});
		addEvent(left,'mouseout', function() { clearInterval(this.dx); return false;});
		var right = document.getElementById('right');
		addEvent(right,'mouseover', function() {this.dx=setInterval('scrollTips.arrowScroll(1)',100);return false;});
		addEvent(right,'mouseout', function() { clearInterval(this.dx); return false;});
	},
	mouseScroll : function(e) {
		if (!e) var e = window.event;
		  var scroll = e.detail ? e.detail * 20 : e.wheelDelta / -20;
		if (scroll>=0 ){  
		window.scrollBy(80,0);
		} else  window.scrollBy(-80,0) ; 
	},	
	arrowScroll: function(val) {
		if(val==1) {
			window.scrollBy(70,0);
		} else {
			window.scrollBy(-70,0)
		}
	}
}


function addEvent( obj, type, fn ) {
	if (obj.addEventListener){
		obj.addEventListener( type, fn, false );
	}else if (obj.attachEvent) {
		obj["e"+type+fn] = fn;
		obj[type+fn] = function() { obj["e"+type+fn]( window.event ); }
		obj.attachEvent( "on"+type, obj[type+fn] );
	}
}

function removeEvent( obj, type, fn ) {
	if (obj.removeEventListener){
		obj.removeEventListener( type, fn, false );
	}else if (obj.detachEvent) {
		obj.detachEvent( "on"+type, obj[type+fn] );
		obj[type+fn] = null;
		obj["e"+type+fn] = null;
	}
}

Te agradezco la mano que me estas dando..!
  #6 (permalink)  
Antiguo 22/06/2012, 09:46
Avatar de comodinx  
Fecha de Ingreso: junio-2012
Mensajes: 2
Antigüedad: 11 años, 10 meses
Puntos: 0
Respuesta: Errores en Internet Explorer

Una de las cosas que puede ser, es que el internet explorer se fija en todo. Asique tendrias que poner punto y coma cada ves que finalizes una linea.

Por ejemplo arriba de método que te da error tenes el siguiente código:
Código:
	
// Asi lo tenes vos.
	arrowScroll: function(val) {
		if(val==1) {
			window.scrollBy(70,0);
		} else {
			window.scrollBy(-70,0)
		}
	}

// Asi creo que lo tendrias que tener.
	arrowScroll: function(val) {
		if(val==1) {
			window.scrollBy(70,0);
		} else {
			window.scrollBy(-70,0);
		}
	}
  #7 (permalink)  
Antiguo 22/06/2012, 16:26
Avatar de IsaBelM
Colaborador
 
Fecha de Ingreso: junio-2008
Mensajes: 5.032
Antigüedad: 15 años, 10 meses
Puntos: 1012
Respuesta: Errores en Internet Explorer

comodinx, no revivas temas antiguos. fíjate que el tema tiene 3 años. no creo que continúe esperando una solución
__________________
if(ViolenciaDeGénero) {alert('MUJER ASESINADA');}
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 00:57.