2012-07-26 34 views
0

我可以將其轉換爲外部腳本嗎?是否有可能將此轉換爲外部.js

<center> 
Users online: 

<blink> 
<sup> 
<form> 
<TABLE style="background-color:white" border="2"> 
<TD><div id="text"></div></TD> 
</TABLE> 
</form> 
</sup> 
</blink> 
</center> 
<script type="text/javascript"> 
Function.prototype.allowSleep = function(n) { 
    var i, f; 
    if (!/^[$\w]+$/.test(n)) return; 
    i = 0; 
    f = this.toString().replace(/sleep\((.*?)\);/g , function(f,t) {i++; return n+".f"+i+" = function() {"+n+".func"+i+"();};\nsleep("+t+","+n+".f"+i+");\n"+(i==1?"":"}\n")+n+".func" + i +" = function() {";}); 
    eval(n+'='+f+'\n}'); 
} 
sleep = function(t,f) { 
    if (f === undefined) return; 
    setTimeout(f,t); 
} 

afunc = function() { 
    document.getElementById('text').innerHTML = '1'; 
    sleep(2000); 
    document.getElementById('text').innerHTML = '2'; 
    sleep(2030); 
    document.getElementById('text').innerHTML = '3'; 

} 
afunc.allowSleep('afunc'); // comment 
afunc(); 
</script> 

我保存爲.js文件,但我得到第2行的錯誤...

什麼是.js文件和我怎麼做呢?的xD

我只是想能夠隱藏我的代碼基本上

將我必須點擊一個按鈕來顯示這個還是會出現在網頁上?

+2

.JS文件僅包含js。 – swapnesh 2012-07-26 04:46:57

回答

1

您不能將.js文件保存爲html,只需將以下部分保存在.js文件中。 js幷包含它:

<script type="text/javascript"> 
Function.prototype.allowSleep = function(n) { 
    var i, f; 
    if (!/^[$\w]+$/.test(n)) return; 
    i = 0; 
    f = this.toString().replace(/sleep\((.*?)\);/g , function(f,t) {i++; return n+".f"+i+" = function() {"+n+".func"+i+"();};\nsleep("+t+","+n+".f"+i+");\n"+(i==1?"":"}\n")+n+".func" + i +" = function() {";}); 
    eval(n+'='+f+'\n}'); 
} 
sleep = function(t,f) { 
    if (f === undefined) return; 
    setTimeout(f,t); 
} 

afunc = function() { 
    document.getElementById('text').innerHTML = '1'; 
    sleep(2000); 
    document.getElementById('text').innerHTML = '2'; 
    sleep(2030); 
    document.getElementById('text').innerHTML = '3'; 

} 
afunc.allowSleep('afunc'); // comment 
afunc(); 
</script> 
+0

我的語法錯誤行1代碼1 – 2012-07-26 05:42:47

相關問題