使用第三方库
一般用户可忽略本节内容。
本节内容适合已经掌握JavaScript和CSS,希望使用第三方JavaScript库的用户。
使用第三方的Javascript库和使用本地库并没有差别,下面是一个使用jQuery库的例子。
1、在"d:\web"目录下,建立一个子目录lib,在这个子目录中新建一个文本文件,文件名为"test.js",文件内容为:
$(document).ready(function(){
    $('button').click(function(){
        $('div').animate({left:'250px'});
    });
});
2、HttpRequest事件代码设置为,在有变化的地方,我加上了注释:
Dim
fl As
String = 
"d:\web\" & 
e.path
If filesys.FileExists(fl)
    Dim idx
As Integer 
= fl.LastIndexOf(".")
    Dim ext
As String  
= fl.SubString(idx)
    Select Case
ext
        Case 
".jpg",".gif",".png",".bmp",".wmf",".js",".css"
            e.WriteFile(fl)
    End 
Select
Else
    Dim sb
As New
StringBuilder
    sb.AppendLine("<!doctype 
html>")
    sb.AppendLine("<html>")
    sb.AppendLine("<head>")
    sb.AppendLine("<meta 
charset='utf-8'>")
    sb.AppendLine("<title>jQuery测试</title>")
    sb.AppendLine("<script 
src='http://cdn.static.runoob.com/libs/jquery/1.10.2/jquery.min.js'></script>")
'引入jQuery库
    sb.AppendLine("<script 
src='./lib/test.js'></script>") '引入本地库
    sb.AppendLine("</head>")
    sb.AppendLine("<body>")
    sb.AppendLine("<button>开始动画</button><br/><br/>")
    sb.AppendLine("<div 
style='background:#98bf21;height:100px;width:100px;position:absolute;'>")
    sb.AppendLine("</body>")
    sb.AppendLine("</html>")
    e.WriteString(sb.ToString)
End 
If
在浏览器显示的结果如下,单击“开始动画”按钮,绿色方框会移动:
