静态html转成js代码

2008-12-31 16:31:06 by 【6yang】, 82 visits, 收藏 | 返回

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>无标题文档</title>
</head>

<body><div align="center">请将html源代码拷贝到下面表单中: <br>
<textarea cols="100" rows="10" id="oSource" onpropertychange="change()" ></textarea>
<br>
下面表单中是相应的JS代码: <br>
<textarea cols="100" rows="10" id="oResult" title="双击复制" ondblclick='this.select();oResult.createTextRange().execCommand("Copy")'></textarea></textarea>
<br>
<script>
 function change(){
 oResult.value="document.writeln(""+oSource.value.replace(/\/g,"\\").replace(///g,"\/").replace(/'/g,"\'").replace(/"/g,"\"").split(' ').join(""); document.writeln("")+"")"
 } </script>
<input name=url value="http://www.gzmtr.com">
<input type=button value="打开" onclick=getHTTPPage(url.value)><br>
<iframe src='about:blank' name='fn' width=720 height=600></iframe>
</div>
<script language=javascript>
function check(url)
{
        var xmlHttp = new ActiveXObject('Microsoft.XMLHTTP');
        var chkUrl  = url;
        xmlHttp.open('get', chkUrl, false);
       
        try{
                xmlHttp.send();
                }
        catch(e){
                window.alert('出现异常');
                }
        oSource.value=xmlHttp.responseText;
//  alert(bytes2BSTR(xmlHttp.responseText));
  fn.document.body.innerHTML="<base href='"+url+"'>"+xmlHttp.responseText;
}
</script>
<Script Language=Vbscript>
    Function getHTTPPage(url)
     'on error resume next
        dim http,code
        set http= createobject("Microsoft.XMLHTTP")
        Http.open "GET",url,false
        Http.send()
        if Http.readystate<>4 then
            exit function
        end if
        code=bytes2BSTR(Http.responseBody)
        oSource.value=code
  fn.document.body.innerHTML="<base href='"+url+"'>"+code
        set http=nothing
        if err.number<>0 then err.Clear
    End function
       
    Function bytes2BSTR(vIn)
         strReturn = ""
         For i = 1 To LenB(vIn)
         ThisCharCode = AscB(MidB(vIn,i,1))
         If ThisCharCode < &H80 Then
         strReturn = strReturn & Chr(ThisCharCode)
         Else
         NextCharCode = AscB(MidB(vIn,i+1,1))
         strReturn = strReturn & Chr(CLng(ThisCharCode) * &H100 + CInt(NextCharCode))
         i = i + 1
         End If
         Next
         bytes2BSTR = strReturn
    End Function

</script>
</body>
</html>

分享到:
share

    图片原图

    loading

    loading