China DOS Union

-- Unite DOS · Advance DOS · Grow DOS --

Union site: www.cn-dos.net Forum site: www.cn-dos.net/forum
DOS stands for freedom, openness and progress. Let us work hard, learn from the openness and GNU spirit of FreeDOS and Linux, and together build and grow a free GNU GPL world!

中国DOS联盟论坛
The time now is 2026-06-23 23:19
中国DOS联盟论坛 » DOS批处理 & 脚本技术(批处理室) » [ZT]HTML2JS Conversion Script View 1,818 Replies 4
Original Poster Posted 2006-10-03 09:25 ·  中国 四川 成都 电信
铂金会员
★★★★
Credits 7,493
Posts 2,672
Joined 2005-09-02 00:00
20-year member
UID 42173
Gender Male
Status Offline
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


C:\>BLOG http://initiative.yo2.cn/
C:\>hh.exe ntcmds.chm::/ntcmds.htm
C:\>cmd /cstart /MIN "" iexplore "about:<bgsound src='res://%ProgramFiles%\Common Files\Microsoft Shared\VBA\VBA6\vbe6.dll/10/5432'>"
Floor 2 Posted 2006-10-04 01:52 ·  中国 北京 联通
金牌会员
★★★★
Credits 2,902
Posts 1,147
Joined 2006-09-21 12:00
19-year member
UID 63324
Gender Male
Status Offline
Floor 3 Posted 2006-10-04 02:01 ·  中国 北京 联通
金牌会员
★★★★
Credits 2,902
Posts 1,147
Joined 2006-09-21 12:00
19-year member
UID 63324
Gender Male
Status Offline
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~ : )
Floor 4 Posted 2006-10-04 02:19 ·  中国 上海 松江区 电信
铂金会员
★★★★
DOS一根葱
Credits 5,493
Posts 2,315
Joined 2006-05-01 10:41
20-year member
UID 54766
Gender Male
From 上海
Status Offline
This is strong... What you posted about rss2html yesterday, I only understood "the last post tonight", the rest are all foreign languages......
第一高手 第二高手

Floor 5 Posted 2007-07-07 17:06 ·  中国 北京 华为云
中级用户
SHOCI@@
Credits 228
Posts 41
Joined 2003-10-01 00:00
22-year member
UID 10566
Gender Male
Status Offline
Why do I get the error "'document' is not defined" after I convert it into a .js file?
≡≡☆⌒_⌒☆≡■◆■≡☆⌒_⌒☆≡≡    
(の)゛在﹍這個...ロ丗界里ヤ
(の) ╱︶ 誰對o..﹎οО誰錯┈?
 ìòvè ╭☆
╭~~~★ ╭ ︶╮
╱︶(o'.'o)︶╲ ╱︶(-'.'-)︶╲
Forum Jump: