Javascript 代码的html文件

'HTML2JS转换脚本,使用方法:将此文件放在sendto文件中,然后在htm文件上点右键,发送到,html2js.vbs,输入要生成的格式js或asp 脚本会生成一个同名的文件,但扩展名为.js或.asp或者将html文件拖放在此文件上。
'海娃@http://www.51windows.Net
Set ArgObj = WScript.Arguments
FilePath=ArgObj(0)

dim FSO,file,str1,str
set FSO=CreateObject("scripting.filesystemobject")
set file=FSO.OpenTextFile(FilePath,1)

ConvertType = inputbox("请输入要换类型,js或asp","请输入要换类型,js或asp","js")
 if trim(lcase(ConvertType)) = "js" then
 str = "//51windows.Net html2js转换脚本@"& Now() & vbnewline
 while not file.atendofstream
  str1=file.readline
  if len(str1)>0 then
   str1= Replace(str1,"\","\\")
   str1= Replace(str1,"/","\/")
   str1= Replace(str1,"""","\""")
   str1 = "document.writeln("""&str1&""");"&vbnewline
  str = str & str1
  end if
 wend

 Set fout = fso.CreateTextFile(FilePath & ".js")
 fout.WriteLine str
 fout.close
 msgbox "已经生成"
elseif trim(lcase(ConvertType)) = "asp" then

 str = "'51windows.Net html2js转换脚本@"& Now() & vbnewline
 while not file.atendofstream
  str1=file.readline
  if len(str1)>0 then
   str1= Replace(str1,"%>","%\>")
   str1= Replace(str1,"""","""""")
   str1 = "Response.write """&str1&""" & vbNewLine "&vbnewline
  str = str & str1
  end if
 wend

 Set fout = fso.CreateTextFile(FilePath & ".asp")
 fout.WriteLine "<%"& vbnewline & str & "%>"
 fout.close
 msgbox "已经生成"
else
 msgbox "操作取消"
end if

你可能感兴趣的:(JavaScript)