选择显示字体大小

wap中实现文字滚动

今天发一篇有关如何在wap中实现文字滚动动画的教材
虽说没有很大的实际意义,在wap中没有多少用武之处,但通过这次练习可以了解到ontimer事件的作用

首先说说动画,学flash的人就马上会想到帧,在单位时间内播放多少帧就能实现动画的效果(不过文字滚动在html网页中也能用marquee实现效果)
wap中实现文字滚动的效果就只能利用动画的原理实现,因为wml中没有marquee,但是有card 的ontimer事件
ontimer类似<meta http-equiv="refresh" content="300;url=main.asp">和javascript中的settimeout方法,用于指定一个事件。当<timer/> 标签指定的时间到期后,浏览器就执行ontimer所指定的这个事件。
ontimer可以是一个url地址,一个卡片组,一个wml网页,一幅图像或其他符合url定位的规则的文件。
<timer/>标签指定的时间为正整数,单位大小为1/10秒。

ontimer时间只能包含在card元素或template元素的标签中进行定义,其语法形式如下:
<card id="name" title="label" newcontext="boolean" ordered="true" onenterforward="href" onenterbackward="href" ontimer="href">
内容(content)
</card>
或:
<template onenterforward="href" onenterbackward="href" ontimer="href">
内容(content)
</template>
ontimer事件只有一个属性,即ontimer。
它用于指定一个超链(href)的url地址,指定时间timer过期的时候,用户浏览器就会按照超链(href)的url打开相应的卡片或者文件。

测试一个例子
<card id="c1" title="c1" ontimer="#c2">
<timer value="20"/>
x1
</card>
<card id="c2" title="c2" ontimer="#c1">
x2
<timer value="50"/> 
</card>

效果为:打开页面后显示x1 2秒后跳到第二个名为c2的card 显示x2 5秒后跳回第一个卡片

一般html页面中文字滚动效果都是自下而上

可以做这样的设计
第一个卡片显示内容
------------------

xxxxxxxxxxxxxxxxxx
------------------


代码为:
------------------
<br/><br/><br/>
xxxxxxxxxxxxxxxxxx
------------------

第二个卡片显示内容
------------------


xxxxxxxxxxxxxxxxxx

------------------

代码为:
------------------
<br/><br/>
xxxxxxxxxxxxxxxxxx
------------------

这样配合ontimer事件就能实现文字向上移一行的效果

完整代码如下:

<%@ language=vbscript %>
<% response.contenttype="text/vnd.wap.wml" %>
<?xml version="1.0" encoding="gb2312"?>

<!doctype wml public "-//wapforum//dtd wml 1.1//en" "http://www.wapforum.org/dtd/ wml_1.1.xml">

<wml>
<%
dim mystr
mystr="文字文字文字文字文字"

'mystr 可由数据库中读出

const mheight=6

'定义滚动高度

const speed=30

'定义滚动速度,快慢自己决定,不过太快小心关不掉^-^

for i= 1 to mheight

if i=mheight then
ii=1
else
ii=i+1
end if
'判断是不是最后一张卡片

response.write ("<card id='c"&i&"' title='c"&i&"' ontimer='#c"&ii&"'>"&vbcrlf)
response.write ("<timer value='"&speed&"'/>"&vbcrlf)

brcount=mheight-i
for j1=0 to brcount-1
response.write ( "<br/>"&vbcrlf)
next
response.write ( mystr&vbcrlf)

response.write ("</card>"&vbcrlf)
next
'写出全部卡片

%>
</wml>


最后欢迎大家访问的我wap站点,http://wap.f-a2005.com 或者http://myfa.top.163.com
绝对免费!


 


关键字 本文所属关键字

相关 与本文相关文章

分类 所有文章关键字导航

源码编程相关

Java   Asp   PHP   .Net   XML   C/C++   CGI   VB   Jsp   J2ee   J2se   J2me   EJB   Servlet   Tomcat   Resin   Struts   Weblogic   Eclipse   ANT   GUI   JMS   Web servise   IDEA   Webphere   Hibernate   Spring   Jboss   Applet   Swing   Socket   Javamail   Perl   Ajax   P2P   安全   模式   框架   测试   开源   游戏

SQL数据库相关

My-SQL   Ms-SQL   Access   DB2   Oracle   Sybase   SQLserver   索引   存储过程   加密   数据库   分页   视图  

手机无线相关

3G   Wap   CDMA   GRPS   GSM   IVR   彩信   短信   无线   增值业务

网页设计制作相关

HTML   CSS   网页配色   网页特效   Javascript   VBscript   Dreamweaver   Frontpage   JS   Web   网站设计

网站建设推广相关

建站经验   网站优化   网站排名   推广   Alexa

操作系统/服务器相关

Windows XP   Windows 2000   Windows 2003   Windows Me   Windows 9.x   Linux   UNIX   注册表   操作系统   服务器   应用服务器

图形图像多媒体相关

Photoshop   Fireworks   Flash   Coreldraw   Illustrator   Freehand   Photoimpact   多媒体   图形图像

标准 网站致力的规范

Valid CSS!

无不良内容,无不良广告,无恶意代码

Valid XHTML 1.0 Transitional

creativecommons