¿Cómo incluir text/javascript y text/css en DOC XHTML?

1 view
Skip to first unread message

webn...@gmail.com

unread,
Jul 16, 2006, 10:34:47 AM7/16/06
to WebNewbie
Estos tipos de textos, dentro de un documento se deben de incluir entre
las etiquetas "head ", aunque también se pueden incluir dentro de la
etiqueta "body":

Código:
######################################################################
<html xmlns="http://www.w3.org/2002/06/xhtml2" xml:lang="es">
<head>
<title>Un documento con un tratante</title>
<handler type="text/x-vbscript"
src="http://example.org/progs/vbcalc">
<handler type="text/javascript">

...algun JavaScript en linea...

</handler>
</handler>
</head>
<body>
<handler type="text/x-perl">

... algún script Perl...

</handler>
</body>
</html>
######################################################################


Por lo general lo incluimos de la siguiente manera:

Código:
######################################################################
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="es" >
<head>
<title>Un documento con un tratante</title>
<script type="text/javascript" src="js_paginator.js"></javascript>
<script type="text/javascript">

...algun JavaScript en linea...

</script>
</head>
<body>
<script type="text/javascript">

... algún JavaScript en linea...

</script>
</body>
</html>
######################################################################


El texto dentro de las etiquetas "javascript" o "handler"
se deben de insertar de la siguiente manera:

Código:
######################################################################
<script type="text/javascript"><![CDATA[
...
]]></script>
######################################################################

Pero como existirán navegadores que no lo interpretan como tal, una
forma universal de hacerlo, sería así:

Código:
######################################################################
<script type="text/javascript"><!--//--><![CDATA[//><!--
...
//--><!]]></script>
#####################################################################


Así es la forma correcta de enviarlo, tanto al servirlo como:
aplication/xml, aplication/xhtml+xml y text/html.


Para hojas de estilo, tipo text/css, se insertan al igual que al
insertar código javascript, mientras que la forma universal, varía:

Código:
#####################################################################
<style type="text/css"><!--/*--><![CDATA[/*><!--*/
...
/*]]>*/--></style>
#####################################################################

Reply all
Reply to author
Forward
0 new messages