中国DOS联盟论坛

China DOS Union

-- Unite DOS · Advance DOS · Grow DOS --
Union site: www.cn-dos.net Forum site: www.cn-dos.net/forum
Guest | Log in | Register | Members | Search | China DOS Union
中国DOS联盟论坛
The time now is 2026-08-10 15:18
47,811 topics / 349,897 posts / today 0 new / 48,255 members
DOS批处理 & 脚本技术(批处理室) » [ZT]HTML2JS Conversion Script
Printable Version  1,883 / 4
Floor1 electronixtar Posted 2006-10-03 09:25
铂金会员 Posts 2,672 Credits 7,493
HTML2JS Conversion Script
From: 51windows.Net  Author: Haiwa

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

HTML2JS Conversion Script, usage: Place this file in the sendto folder, then right-click on an htm file, select Send To, html2js.vbs, enter the format to generate (js or asp). The script will generate a file with the same name but with the extension .js or .asp, or drag an html file onto this file.

Supports html files with Javascript code

Code: html2js.vbs


'HTML2JS Conversion Script, usage: Place this file in the sendto folder, then right-click on an htm file, select Send To, html2js.vbs, enter the format to generate (js or asp). The script will generate a file with the same name but with the extension .js or .asp, or drag an html file onto this file.
'Haiwa@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("Please enter the type to convert, js or asp","Please enter the type to convert, js or asp","js")
if trim(lcase(ConvertType)) = "js" then
str = "//51windows.Net html2js conversion script@"& 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 "Has been generated"
elseif trim(lcase(ConvertType)) = "asp" then

str = "'51windows.Net html2js conversion script@"& 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 "Has been generated"
else
msgbox "Operation canceled"
end if

Floor2 redtek Posted 2006-10-04 01:52
金牌会员 Posts 1,147 Credits 2,902
Floor3 redtek Posted 2006-10-04 02:01
金牌会员 Posts 1,147 Credits 2,902
If the organization holds a VBScript or batch script training class, face-to-face! Each person pays N yuan as a symbolic fee for the venue training. After the training, we eat to our hearts' content, eat until we're dizzy and then disperse~ : ) Maybe in the future, face-to-face training classes will become more and more popular~ : )
Floor4 fastslz Posted 2006-10-04 02:19
铂金会员 Posts 2,315 Credits 5,493 From 上海
This is strong... What you posted about rss2html yesterday, I only understood "the last post tonight", the rest are all foreign languages......
Floor5 SHOCIAA Posted 2007-07-07 17:06
中级用户 Posts 41 Credits 228
Why do I get the error "'document' is not defined" after I convert it into a .js file?
[ Contact the Union admin team - 中国DOS联盟 - Standard version ]
Sponsored by ifanr Inc | © 2001–2023