Ir para conteúdo

POWERED BY:

Arquivado

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

floating

em DIV dentro de uma Função

Recommended Posts

Olá pessoal estou com um problema quando vou validar meu código...

é o seguinte tenho ese código:

 

<body><script type="text/javascript">if(bw.bw) document.write('<div id="divloadcont"></div>') </script>
Mas o WC da o seguinte erro:

# Error Line 102 column 22: document type does not allow element "div" here.

 

'<div id="divloadcont"></div>'

 

The element named above was found in a context where it is not allowed. This could mean that you have incorrectly nested elements -- such as a "style" element in the "body" section instead of inside "head" -- or two elements that overlap (which is not allowed).

 

One common cause for this error is the use of XHTML syntax in HTML documents. Due to HTML's rules of implicitly closed elements, this error can create cascading effects. For instance, using XHTML's "self-closing" tags for "meta" and "link" in the "head" section of a HTML document may cause the parser to infer the end of the "head" section and the beginning of the "body" section (where "link" and "meta" are not allowed; hence the reported error).

 

Alguém saberia como consertar isso??

 

Valeu galera.

 

Grande Abraço!!

 

 

floating...

Compartilhar este post


Link para o post
Compartilhar em outros sites

Aparentemente o problema citado não está no código acima mas, pode estar sendo gerado por outro bloco de código.

 

Rodei o código citado num HTML puro da seguinte forma:

<html>   <head>	  <style type="text/css">		 #divloadcont {background-color:yellow;border:red solid 1px;width:100px;height:30px;}	  </style>   </head>	   <body>	  <div id='bw'><div id='bw'></div></div>	  <script type="text/javascript">		 if(bw.bw) document.write('<div id="divloadcont"></div>')	  </script>   </body></html>

FUNCIONOU PERFEITAMENTE!!!

 

Dá uma revisada no código da tua página e, se for o caso, poste um pouco mais sobre ele para que possamos dar uma olhada.

Precisa verificar se o lugar onde você está tentando escrever o DIV permite isto. Neste caso, o problema não está o document.write... e sim na localização da futura DIV.

 

http://forum.imasters.com.br/public/style_emoticons/default/joia.gif Martinelli

Compartilhar este post


Link para o post
Compartilhar em outros sites

Obrigado Martinelli, mas como tive que fazer para que o W3C validasse meu código:

está tudo no <head></head>:

 

<style type="text/css" ><!--div#divloadcont{	position:absolute; 	background-image: url('carregando.gif');	background-repeat: no-repeat;	background-position: 50% 30%;	background-attachment: fixed;	width:100%; 	overflow:hidden; 	height:1009px; 	margin:0px; 	padding:0px; 	top:0px; 	left:0px; 	background-color:white; 	font-family:arial,helvetica;	z-index:100;}//--></style>

<script type="text/javascript" language="JavaScript"><!--if (bw.bw) { 	document.write(	'<div id="divloadcont"></div>'	)			}//--> </script>

<script type="text/javascript" language="JavaScript"><!-- function checkBrowser(){  this.ver=navigator.appVersion  this.dom=document.getElementById?1:0  this.ie6=(this.ver.indexOf("MSIE 6")>-1 && this.dom)?1:0;  this.ie5=(this.ver.indexOf("MSIE 5")>-1 && this.dom)?1:0;  this.ie4=(document.all && !this.dom)?1:0;  this.ns5=(this.dom && parseInt(this.ver) >= 5) ?1:0;  this.ns4=(document.layers && !this.dom)?1:0;  this.bw=(this.ie6 || this.ie5 || this.ie4 || this.ns4 || this.ns5)  return this } bw=new checkBrowser() function hideIt(div){  if(bw.bw){   div="divloadcont"   obj=bw.dom?document.getElementById(div).style:bw.ie4?document.all[div].style:bw.ns4?document[div]:0;    obj.visibility='hidden'  } } onload=hideIt;//-->  </script>

Parece que o W3C não permite que DIVs fiquem dentro do Head, mas ... mas eu aqui no trabalho uso Ubuntu (Linux) e tem algun bug, deixa eu te explicar.. ele faz o loading perfeito, fecha depois certinho, só que o mouse fica piscando e meio que para o firefox, fica tudo lento, como se o gif ainda estivesse lá em cache sobre-carregando a memória, se possível dê uma olhada, por favor...

 

www.floating.com.br

 

é estranho pois no Windows funciona perfeito!! e o W3C validou, mas devo estar fazendo algo de errado!

esse problema deve estar ocorrendo em outros códigos, mas acredito que poucos programadores se preocupam com a validação do W3C!!

 

Mais uma vez, obrigado!!

 

 

 

...floating

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.