Manual de WML - Trucos


Las URL relativas o absolutas

Puede ocurrir que el dispositivo WAP o el gateway no interprete correctamente una URL relativa. Para evitar esto ser recomienda usar la URL absoluta:

NO
<a href="../foo/bar.wml">
<a href="#myID">
<a ref="http://my.server.com/foo/bar.wml">
<a href="http://my.server.com/foo/bar.wml#myID">


Nombre de variables y ficheros

No olvides que los datos se envian y reciben a través del aire. La velocidad suele se de 9600. Intenta que se envien el menor volumen de datos posible.
Idea 1: Usa nombres de ficheros lo más cortos posibles. Ej: http:"//my.server.com/i.wml" mejor que http://my.server.com/index.wml
Idea 2: Usa nombres de variables lo más cortos posibles. Si usas menos de 25 variables lo mejor es que uses las letras del alfabeto.



Imágenes

Cuidado. No todos los dispositivos WAP aceptan imágenes. Utilízalas lo menos posible. Alguna SDK si las aceptan, pero... Y si las utilizas no te olvides nunca de poner el atributo alt <img src="imagen.gif" alt="Icono" />



Nombre de variables y ficheros

¿Has intentado alguna vez escribir un password en un teléfono móvil? Es muy fácil en un PC o en un PDA, pero en un teléfono... Procura no usar el atributo type="password" en los input



¿Listas o Links normales?

Hay dos formas de crear una lista de 2 links, con un select o con a. Recomendamos la segunda por lo que se explica abajo

NO
<select ivalue="0">
<option onpick="#Card2">Link 1</option>
<option onpick="#Card3">Link 2</option>
</select>
<p><a href="#Card2">Link 1</a></p>
<p><a href="#Card3">Link 2</a></p>
Así se va a ver
Así se va a ver
aaaa
bbb
El problema es que como aparece
seleccionado el primer link,
no podemos accionarlo, y
si bajamos al segundo,
se inicializa el evento onpick
y nos vamos a al Card3
Link 1
Link 2


Newcontext="true"

&Iquest;Has visto en el código de alguna página <card id="card1" title="Currency" newcontext="true">? ¿ Lo has probado?
Si pones ese atributo, las variables se borran, incluso la history, por lo que no se puede usar el back. Para inicializar variables es mejor
<card title="Titulo">
<<onevent type="onenterforward">
<refresh>
<setvar name="Var1" value=" "/>
<setvar name="some_var2" value=" "/>
</refresh>
</onevent>
...
</card>



Pasar datos a ASP o CGI

Por ejemplo con un input:
<input format="NN" name="Var1" title="Var1:"/>
<do type="accept" label="Mandar:">
<go href="http://*****/test.asp?datos=$(Var1)"/>



Detectar en el servidor si se accede con un dispositivo WAP

Sorry, pero no lo he traducido... XP
Sacado de http://www.egroups.com/group/wmlprogramming

I tried to redirect my browser clients using ASP and following your sample code. For some reason the content type is text/html. I submit the code see if any of you can see whats wrong. The redirect woks fine when I use the web browser.

---------code-----------------------------------------------------
<%Response.ContentType = "text/vnd.wap.wml"%>
<% Dim uastring, wmlURL, htmlURL
uastring = request.ServerVariables("HTTP_USER_AGENT")
wmlURL = "/martin/index.wml"
htmlURL = "some URL"
If (InStr(uastring,"UP") Or InStr(uastring, "Nokia") Or InStr(uastring,
"Wap")) Then
     Response.Redirect wmlURL
else
     Response.Redirect htmlURL
End If %>
-------End of code---------------------------------------
Marco
 

The only problem with this approach is when you encounter a phone that does not support WMLScript, or your site gets hit by an HTML client. You're much better off checking on the server end first. This is a trivial exercise in just about any language, Perl, ASP, Java, etc...

In Perl 5
#!/usr/local/bin/perl5

$ua = $ENV{"HTTP_USER_AGENT"};
if ($ua =~ "UP"){ print "Status: 302 Moved Temporarily\r Location: <one location>"; } elsif($ua =~ "Nokia"){ ...

You get the picture.

In asp, this construct would look like:

Dim uastring
uastring = request.ServerVariables("HTTP_USER_AGENT")
If (InStr(uastring,"UP"))Then Response.Redirect(<onelocation>)

and in a Java Servlet it would look like this:

String ua = req.getHeader(HTTP_USER_AGENT);
if (ua.indexOf("UP")!= null){
res.setStatus(res.SC_MOVED_TEMPORARILY);
res.setHeader("Location", <one location>);


En breve ofreceremos más cosas... y si quieres...

Si quieres colaborar pincha AQUI. Hay importantes beneficios para los colaboradores.

Si quieres que tu página forme parte del Anillo de páginas WAP envíanos un mail con el subject anillo y la URL de tu página pulsando AQUI --> wapfacil@pagina.de

Si quieres recibir un email cuando se actualize el curso de WML envíanos un mail con el asunto News y tus datos(Nombre, la contraseña que quieras para usos futuros de nuestros afiliados y tu email) wapfacil@pagina.de

Atrás

http://pagina.de/wapfacil
© WapFacil 1999