HTML file of JavaScript code

Source: Internet
Author: User

'Html2js conversion script. Usage: place the file in the sendto file, right-click the HTM file, and send it to html2js. vbs: Enter the JS or ASP script to generate a file with the same name, but the extension is. JS or. ASP or drag and drop an HTML file on this file.
'Baby @ 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 ("Enter the type to change, JS or ASP", "Enter the type to change, 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 "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 "generated"
Else
Msgbox "Operation canceled"
End if

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.