Ir para conteúdo

POWERED BY:

Arquivado

Este tópico foi arquivado e está fechado para novas respostas.

digOw

Adaptar JS no Firefox

Recommended Posts

Conheço quase nada de JS, e estou desenvolvendo um site em CSS, até que está indo, mas me meti a colocar um JS e ele nao se adapta ao Firefox. Se alguém puder ajudar. Obrigado.Nao sei se devo colocar link, mas acho q nao, então o codigo é esse:

var message= new Array()message[0]="VASCO|Vasco para todos |http://www.netvasco.com.br"message[1]="GLOBO|Globo para todos|http://www.globo.com"message[2]="FUTEBOL|Futebol para todos |http:/www.lancenet.com.br"// height of the scrollerbox (pixels)var scrollerheight=20// width of the titlezone (pixels)var titlezonewidth=162// width of the copyzone (pixels)var copyzonewidth=617// horizonal position: distance to the top border of the window (pixels)var scrollertop=624// vertical position: distance to the left border of the window (pixels)var scrollerleft=187// borderwidth of the scrollervar scrollerborder=2// backgroundcolor for the titlezonevar titlezonebg="330066"// backgroundcolor for the copyzonevar copyzonebg="CC0000"// backgroundcolor for the scrollervar scrollbg="AAAAAA"// The target of your links// possible values are '_blank', '_self', '_top', '_parent' or the name of// the target window for instance 'main'var targetlink="_blank"// font attributes of the titlevar font_titleface="Verdana"var font_titlecolor="FFFFFF"var font_titlesize=1// font attributes of the copytextvar font_copyface="Verdana"var font_copycolor="FFFFFF"var font_copysize=1// set 1 for bold title, set 0 for normal titlevar titlebold=1// set 1 for bold copy, set 0 for normal copyvar copybold=1// set 'right', 'left' or 'center' to align the titlevar titlealign="center"// set 'right', 'left' or 'center' to align the copyvar copyalign="center"// standstill between the messages (milliseconds)var standstill=4000// Do not edit below this linevar pre_titleboldvar after_titleboldvar pre_copyboldvar after_copyboldvar cliptop=0var clipbottom=0var clipleft=0var clipright=titlezonewidth+copyzonewidthvar i_message=0var mes_joinedvar mes_splitvar contenttextvar contentbg=""var step=1var pause=20if (titlebold==1) { pre_titlebold="" after_titlebold=""}else if (titlebold==0) { pre_titlebold="" after_titlebold=""}if (copybold==1) { pre_copybold="" after_copybold=""}else if (copybold==0) { pre_copybold="" after_copybold=""}function initiate() { mes_joined=message[i_message] mes_split=mes_joined.split("|") contenttext="<table cellpadding=4 cellspacing=0 border=0>" contenttext+="<tr valign='top'>" contenttext+="<td align="+titlealign+" width="+titlezonewidth+" height='"+scrollerheight+"' bgcolor='"+titlezonebg+"'>" contenttext+="<a href='"+mes_split[2]+"' target='"+targetlink+"'>" contenttext+="<font face='"+font_titleface+"' color='"+font_titlecolor+"' size='"+font_titlesize+"'>" contenttext+=pre_titlebold contenttext+=mes_split[0] contenttext+=after_titlebold contenttext+="" contenttext+="<td align="+copyalign+" width="+copyzonewidth+" height='"+scrollerheight+"' bgcolor='"+copyzonebg+"'>" contenttext+="<font face='"+font_copyface+"' color='"+font_copycolor+"' size='"+font_copysize+"'>" contenttext+=pre_copybold contenttext+=mes_split[1] contenttext+=after_copybold contenttext+="" contenttext+="" var bg_width=titlezonewidth+copyzonewidth+2*scrollerborder var bg_height=scrollerheight+2*scrollerborder contentbg="<table width="+bg_width+" height='"+bg_height+"' cellpadding=0 cellspacing=0 border='"+scrollerborder+"'><tr><td bgcolor='"+scrollbg+"'>" if (document.all) { scrollertext.innerHTML=contenttext scrollerbg.innerHTML=contentbg document.all.scrollertext.style.posTop=scrollertop+scrollerheight document.all.scrollertext.style.posLeft=scrollerleft document.all.scrollerbg.style.posTop=scrollertop-scrollerborder document.all.scrollerbg.style.posLeft=scrollerleft-scrollerborder document.all.scrollertext.style.clip="rect("+cliptop+" "+clipright+" "+clipbottom+" "+clipleft+")" scrollin() } if (document.layers) { document.scrollertext.document.write(contenttext) document.scrollertext.document.close() document.scrollerbg.document.write(contentbg) document.scrollerbg.document.close() document.scrollertext.top=scrollertop+scrollerheight document.scrollertext.left=scrollerleft document.scrollerbg.top=scrollertop-scrollerborder document.scrollerbg.left=scrollerleft-scrollerborder document.scrollertext.clip.left=clipleft document.scrollertext.clip.right=clipright document.scrollertext.clip.top=cliptop document.scrollertext.clip.bottom=clipbottom scrollin() }}function scrollin(){ if (document.all){ if (document.all.scrollertext.style.posTop>scrollertop) { clipbottom+=step document.all.scrollertext.style.clip="rect("+cliptop+" "+clipright+" "+clipbottom+" "+clipleft+")" document.all.scrollertext.style.posTop-=step var timer=setTimeout("scrollin()",pause) } else { clearTimeout(timer) var timer=setTimeout("scrollout()",standstill) } } if (document.layers){ if (document.scrollertext.top>scrollertop) { clipbottom+=step document.scrollertext.clip.left=clipleft document.scrollertext.clip.right=clipright document.scrollertext.clip.top=cliptop document.scrollertext.clip.bottom=clipbottom document.scrollertext.top-=step var timer=setTimeout("scrollin()",pause) } else { clearTimeout(timer) var timer=setTimeout("scrollout()",standstill) } }}function scrollout(){ if (document.all){ if (document.all.scrollertext.style.posTop>(scrollertop-scrollerheight)) { cliptop+=step document.all.scrollertext.style.clip="rect("+cliptop+" "+clipright+" "+clipbottom+" "+clipleft+")" document.all.scrollertext.style.posTop-=step var timer=setTimeout("scrollout()",pause) } else { clearTimeout(timer) changemessage() } } if (document.layers){ if (document.scrollertext.top>(scrollertop-scrollerheight)) { cliptop+=step document.scrollertext.clip.left=clipleft document.scrollertext.clip.right=clipright document.scrollertext.clip.top=cliptop document.scrollertext.clip.bottom=clipbottom document.scrollertext.top-=step var timer=setTimeout("scrollout()",pause) } else { clearTimeout(timer) changemessage() } }}function changemessage(){ i_message++ if (i_message>message.length-1) {i_message=0} mes_joined=message[i_message] mes_split=mes_joined.split("|") cliptop=0 clipbottom=0 contenttext="<table cellpadding=4 cellspacing=0 border=0>" contenttext+="<tr valign='top'>" contenttext+="<td align="+titlealign+" width="+titlezonewidth+" height='"+scrollerheight+"' bgcolor='"+titlezonebg+"'>" contenttext+="<a href='"+mes_split[2]+"' target='"+targetlink+"'>" contenttext+="<font face='"+font_titleface+"' color='"+font_titlecolor+"' size='"+font_titlesize+"'>" contenttext+=pre_titlebold contenttext+=mes_split[0] contenttext+=after_titlebold contenttext+="" contenttext+="<td align="+copyalign+" width="+copyzonewidth+" height='"+scrollerheight+"' bgcolor='"+copyzonebg+"'>" contenttext+="<font face='"+font_copyface+"' color='"+font_copycolor+"' size='"+font_copysize+"'>" contenttext+=pre_copybold contenttext+=mes_split[1] contenttext+=after_copybold contenttext+="" contenttext+="" if (document.all) { scrollertext.innerHTML=contenttext document.all.scrollertext.style.posTop=scrollertop+scrollerheight document.all.scrollertext.style.posLeft=scrollerleft document.all.scrollertext.style.clip="rect("+cliptop+" "+clipright+" "+clipbottom+" "+clipleft+")" scrollin() } if (document.layers) { document.scrollertext.document.write(contenttext) document.scrollertext.document.close() document.scrollertext.top=scrollertop+scrollerheight document.scrollertext.left=scrollerleft document.scrollertext.clip.left=clipleft document.scrollertext.clip.right=clipright document.scrollertext.clip.top=cliptop document.scrollertext.clip.bottom=clipbottom scrollin() }}

Compartilhar este post


Link para o post
Compartilhar em outros sites

Começando por isto...

onde estiver:

document.all.nomeDoCampo
tem de ser:

document.getElementById("nomeDoCampo")

Compartilhar este post


Link para o post
Compartilhar em outros sites

Deu um erro, mas com o tempo eu vou testando pra corrigir..Há outras alterações à fazer?Abraços..

Compartilhar este post


Link para o post
Compartilhar em outros sites

provavelmente, mas estou de saida agora depois olhamos isso.

Compartilhar este post


Link para o post
Compartilhar em outros sites

me mostra o código do scrollertext e do scrollbg

Compartilhar este post


Link para o post
Compartilhar em outros sites

É esse..

 

<div id="scrollerbg" style="position:absolute;font-weight:bold"></div><div id="scrollertext" style="position:absolute;font-weight:bold"></div>

Compartilhar este post


Link para o post
Compartilhar em outros sites

Então, ao invés de estar fazendo estas verificações para funcionar no IE e no FF,

if (document.all) {scrollertext.innerHTML=contenttextdocument.all.scrollertext.style.posTop=scrollertop+scrollerheight}if (document.layers) {document.scrollertext.document.write(contenttext)document.scrollertext.top=scrollertop+scrollerheight}

Faça assim para que funcione em qualquer browser:

document.getElementById('scrollertext').innerHTML=contenttextdocument.getElementById('scrollertext').style.top=scrollertop+scrollerheight

Acho que a propriedade .style.posTop nem existe nos browsers padronizados como Firefox.

 

Algumas leituras interessantes para scripts cross-browser:

http://www.ecma-international.org/publicat...ds/Ecma-262.htm

http://www.javascriptkit.com/domref/index.shtml

 

F.

Compartilhar este post


Link para o post
Compartilhar em outros sites

Desculpa ser chato mais uma vez, mas eu mudei oq você falou, continuou funcionando no IE e nos outros não.

 

var message= new Array()// Configure each message below like this:// message[indexnumber]="text of title|text of copy|URL of link"// You may add as many messages as you like.message[0]="INTERNET GAMES|The latest games, discussions, tricks and cheats from about.com |http://service.bfast.com/bfast/click?bfmid=7279965&siteid=30125004&bfpage=internetgames3"message[1]="WEB CLIP ART|Collections, creation tricks, tutorials and free tools from about.com|http://service.bfast.com/bfast/click?bfmid=7279965&siteid=30125004&bfpage=webclipart3"message[2]="HAPPY CHATTING|Link to an expert from about.com |http://service.bfast.com/bfast/click?bfmid=7279965&siteid=30125004&bfpage=chatting"// height of the scrollerbox (pixels)var scrollerheight=20// width of the titlezone (pixels)var titlezonewidth=120// width of the copyzone (pixels)var copyzonewidth=440// horizonal position: distance to the top border of the window (pixels)var scrollertop=20// vertical position: distance to the left border of the window (pixels)var scrollerleft=20// borderwidth of the scrollervar scrollerborder=2// backgroundcolor for the titlezonevar titlezonebg="330066"// backgroundcolor for the copyzonevar copyzonebg="CC0000"// backgroundcolor for the scrollervar scrollbg="AAAAAA"// The target of your links// possible values are '_blank', '_self', '_top', '_parent' or the name of// the target window for instance 'main'var targetlink="_blank"// font attributes of the titlevar font_titleface="Verdana"var font_titlecolor="FFFFFF"var font_titlesize=1// font attributes of the copytextvar font_copyface="Verdana"var font_copycolor="FFFFFF"var font_copysize=1// set 1 for bold title, set 0 for normal titlevar titlebold=1// set 1 for bold copy, set 0 for normal copyvar copybold=1// set 'right', 'left' or 'center' to align the titlevar titlealign="right"// set 'right', 'left' or 'center' to align the copyvar copyalign="left"// standstill between the messages (milliseconds)var standstill=4000// Do not edit below this linevar pre_titleboldvar after_titleboldvar pre_copyboldvar after_copyboldvar cliptop=0var clipbottom=0var clipleft=0var clipright=titlezonewidth+copyzonewidthvar i_message=0var mes_joinedvar mes_splitvar contenttextvar contentbg=""var step=1var pause=20if (titlebold==1) {	pre_titlebold="<b>"	after_titlebold="</b>"}else if (titlebold==0) {	pre_titlebold=""	after_titlebold=""}if (copybold==1) {	pre_copybold="<b>"	after_copybold="</b>"}else if (copybold==0) {	pre_copybold=""	after_copybold=""}function initiate() {		mes_joined=message[i_message]		mes_split=mes_joined.split("|")				contenttext="<table cellpadding=4 cellspacing=0 border=0>"		contenttext+="<tr valign='top'>"		contenttext+="<td align="+titlealign+" width="+titlezonewidth+" height='"+scrollerheight+"' bgcolor='"+titlezonebg+"'>"		contenttext+="<a href='"+mes_split[2]+"' target='"+targetlink+"'>"		contenttext+="<font face='"+font_titleface+"' color='"+font_titlecolor+"' size='"+font_titlesize+"'>"		contenttext+=pre_titlebold		contenttext+=mes_split[0]		contenttext+=after_titlebold		contenttext+="</font></a></td>"		contenttext+="<td align="+copyalign+" width="+copyzonewidth+" height='"+scrollerheight+"' bgcolor='"+copyzonebg+"'>"		contenttext+="<font face='"+font_copyface+"' color='"+font_copycolor+"' size='"+font_copysize+"'>"		contenttext+=pre_copybold		contenttext+=mes_split[1]		contenttext+=after_copybold		contenttext+="</font></td></tr>"		contenttext+="</table>"				var bg_width=titlezonewidth+copyzonewidth+2*scrollerborder		var bg_height=scrollerheight+2*scrollerborder				contentbg="<table width="+bg_width+" height='"+bg_height+"' cellpadding=0 cellspacing=0 border='"+scrollerborder+"'><tr><td bgcolor='"+scrollbg+"'> </td></tr></table>"		if (document.getElementById) {		document.getElementById('scrollertext').innerHTML=contenttext		document.getElementById('scrollerbg').innerHTML=contentbg		document.getElementById('scrollertext').style.top=scrollertop+scrollerheight		document.getElementById('scrollertext').style.posLeft=scrollerleft		document.getElementById('scrollerbg').style.posTop=scrollertop-scrollerborder		document.getElementById('scrollerbg').style.posLeft=scrollerleft-scrollerborder		document.getElementById('scrollertext').style.clip="rect("+cliptop+" "+clipright+" "+clipbottom+" "+clipleft+")"		scrollin()	}	if (document.layers) {		document.getElementById('scrollertext').innerHTML=contenttext		document.getElementById('scrollertext').document.close()		document.getElementById('scrollerbg').document.write(contentbg)		document.getElementById('scrollerbg').document.close()		document.getElementById('scrollertext').style.top=scrollertop+scrollerheight		document.getElementById('scrollertext').left=scrollerleft		document.getElementById('scrollerbg').top=scrollertop-scrollerborder		document.getElementById('scrollerbg').left=scrollerleft-scrollerborder		document.getElementById('scrollertext').clip.left=clipleft		document.getElementById('scrollertext').clip.right=clipright		document.getElementById('scrollertext').clip.top=cliptop		document.getElementById('scrollertext').clip.bottom=clipbottom		scrollin()	}}function scrollin(){	if (document.getElementById){		if (document.getElementById('scrollertext').style.posTop>scrollertop) {			clipbottom+=step			document.getElementById('scrollertext').style.clip="rect("+cliptop+" "+clipright+" "+clipbottom+" "+clipleft+")"			document.getElementById('scrollertext').style.posTop-=step			var timer=setTimeout("scrollin()",pause)		}		else {			clearTimeout(timer)			var timer=setTimeout("scrollout()",standstill)		}	}	if (document.layers){		if (document.getElementById('scrollertext').top>scrollertop) {			clipbottom+=step			document.getElementById('scrollertext').clip.left=clipleft			document.getElementById('scrollertext').clip.right=clipright			document.getElementById('scrollertext').clip.top=cliptop			document.getElementById('scrollertext').clip.bottom=clipbottom			document.getElementById('scrollertext').top-=step			var timer=setTimeout("scrollin()",pause)		}		else {			clearTimeout(timer)			var timer=setTimeout("scrollout()",standstill)		}	}}function scrollout(){	if (document.getElementById){		if (document.getElementById('scrollertext').style.posTop>(scrollertop-scrollerheight)) {			cliptop+=step			document.getElementById('scrollertext').style.clip="rect("+cliptop+" "+clipright+" "+clipbottom+" "+clipleft+")"			document.getElementById('scrollertext').style.posTop-=step			var timer=setTimeout("scrollout()",pause)		}		else {			clearTimeout(timer)			changemessage()		}	}	if (document.layers){		if (document.getElementById('scrollertext').top>(scrollertop-scrollerheight)) {			cliptop+=step			document.getElementById('scrollertext').clip.left=clipleft			document.getElementById('scrollertext').clip.right=clipright			document.getElementById('scrollertext').clip.top=cliptop			document.getElementById('scrollertext').clip.bottom=clipbottom			document.getElementById('scrollertext').top-=step			var timer=setTimeout("scrollout()",pause)		}		else {			clearTimeout(timer)			changemessage()		}	}}function changemessage(){		i_message++		if (i_message>message.length-1) {i_message=0}		mes_joined=message[i_message]		mes_split=mes_joined.split("|")		cliptop=0		clipbottom=0				contenttext="<table cellpadding=4 cellspacing=0 border=0>"		contenttext+="<tr valign='top'>"		contenttext+="<td align="+titlealign+" width="+titlezonewidth+" height='"+scrollerheight+"' bgcolor='"+titlezonebg+"'>"		contenttext+="<a href='"+mes_split[2]+"' target='"+targetlink+"'>"		contenttext+="<font face='"+font_titleface+"' color='"+font_titlecolor+"' size='"+font_titlesize+"'>"		contenttext+=pre_titlebold		contenttext+=mes_split[0]		contenttext+=after_titlebold		contenttext+="</font></a></td>"		contenttext+="<td align="+copyalign+" width="+copyzonewidth+" height='"+scrollerheight+"' bgcolor='"+copyzonebg+"'>"		contenttext+="<font face='"+font_copyface+"' color='"+font_copycolor+"' size='"+font_copysize+"'>"		contenttext+=pre_copybold		contenttext+=mes_split[1]		contenttext+=after_copybold		contenttext+="</font></td></tr>"		contenttext+="</table>"		if (document.getElementById) {		document.getElementById('scrollertext').innerHTML=contenttext		document.getElementById('scrollertext').style.top=scrollertop+scrollerheight		document.getElementById('scrollertext').style.posLeft=scrollerleft		document.getElementById('scrollertext').style.clip="rect("+cliptop+" "+clipright+" "+clipbottom+" "+clipleft+")"		scrollin()	}	if (document.layers) {		document.getElementById('scrollertext').innerHTML=contenttext		document.getElementById('scrollertext').document.close()		document.getElementById('scrollertext').style.top=scrollertop+scrollerheight		document.getElementById('scrollertext').left=scrollerleft		document.getElementById('scrollertext').clip.left=clipleft		document.getElementById('scrollertext').clip.right=clipright		document.getElementById('scrollertext').clip.top=cliptop		document.getElementById('scrollertext').clip.bottom=clipbottom		scrollin()	}}

Abraços.

Compartilhar este post


Link para o post
Compartilhar em outros sites

checkei aqui e vi que a proprieda .style.posTop é muito utilizada mas ela só existe no IE. Ela é uma propriedade de CSS, verifica com o pessoal do forum de CSS para ver se existe alguma propriedade similar que funcione nos browsers com padrão W3C.F.

Compartilhar este post


Link para o post
Compartilhar em outros sites

×

Informação importante

Ao usar o fórum, você concorda com nossos Termos e condições.