javascript實現(xiàn)存儲hmtl字符串示例
更新時間:2014年04月25日 10:44:03 作者:
這篇文章主要介紹了javascript實現(xiàn)存儲hmtl字符串示例,需要的朋友可以參考下
復制代碼 代碼如下:
Function.prototype.heredoc = function(){
// 利用 function 的注釋來存儲字符串,而且無需轉義。
var _str = this.toString(),
s_pos = _str.indexOf("/*")+2,
e_pos = _str.lastIndexOf("*/");
return (s_pos<0 || e_pos<0) ? "" : _str.substring(s_pos, e_pos);
}
function fn(){
/*<table>
<tr>
<td>用戶名</td>
<td>密碼</td>
</tr>
<tr>
<td style="widht:20px;">@name</td>
<td>zf123456</td>
</tr>
</table>*/
}
varstr_table=fn.heredoc();
console.log(str_table);
相關文章
javascript函數(shù)中的arguments參數(shù)
arguments當然只在function體內才有意義, arguments.length 返回的是傳入function的實參個數(shù)2010-08-08
JS函數(shù)實現(xiàn)動態(tài)添加CSS樣式表文件
有時會使用一些改變心情方面的想法,比如JS函數(shù)實現(xiàn)動態(tài)添加CSS樣式表文件,這樣就可以做到隨機加載心情文件,需要的朋友可以了解下2012-12-12

