Javascript ÖжÔHTML±àÂëºÍ½âÂëµÄ·½·¨
String.prototype.HTMLEncode = function() {
var temp = document.createElement ("div");
(temp.textContent != null) ? (temp.textContent = this) : (temp.innerText = this);
var output = temp.innerHTML;
temp = null;
return output;
}
String.prototype.HTMLDecode = function() {
var temp = document.createElement("div");
temp.innerHTML = this;
var output = temp.innerText || temp.textContent;
temp = null;
return output;
}
ÉÏÃæ´úÂëת×Ô£ºhttp://www.jb51.net/article/18396.htm
±¾È˶ÔjavascriptµÄºËÐļ¼Êõ²»ÊÇÌ«ÊìϤ£¬ÔÙ¼ÓÉÏÏÖÔÚÓÖÔÚÓò»ÊìϤµÄEXTÀ´±àÐ´Ç°Ì¨Ò³Ãæ´úÂ룬ËùÒÔÖ»µÃÓÃ×µÄ·½·¨£¬²»À©Õ¹String×Ô¼ºÐ´´¦Àíº¯Êý£º
htmlDecode:function(str){
var temp = document.createElement ("div");
temp.innerHTML = str;
var output = temp.innerText || temp.textContent;
temp=null;
return output;
}
htmlEncode:function(str){
var temp = document.createElement ("div");
(temp.textContent != null) ? (temp.textContent = str) : (temp.innerText = str);
var output = temp.innerHTML;
temp = null;
return output;
}
ÆäÖÐÓõ½µÄtextContentºÍinnerText ÊôÐÔÈ¡µ½µÄÄÚÈÝÊÇÒ»ÑùµÄ
ÔÒòÊÇfirefox²»Ö§³ÖinnerTextÊôÐÔ£¬µ«ÆäÌṩµÄtextContentÊôÐÔºÍinnerText¾ßÓÐÒ»ÑùµÄ×÷Óá£ËùÒÔÉÏÃæµÄ´úÂë¿ÉÒÔ¼æÈÝIEºÍfirefox
Ïà¹ØÎĵµ£º
Ò»¡¢»ù±¾Ê¹Ó÷½·¨
prototypeÊôÐÔ¿ÉËãÊÇJavaScriptÓëÆäËûÃæÏò¶ÔÏóÓïÑÔµÄÒ»´ó²»Í¬Ö®´¦¡£
¼ò¶øÑÔÖ®£¬prototype¾ÍÊǓһ¸ö¸øÀàµÄ¶ÔÏóÌí¼Ó·½·¨µÄ·½·¨”£¬Ê¹ÓÃprototypeÊôÐÔ£¬¿ÉÒÔ¸øÀද̬µØÌí¼Ó·½·¨£¬ÒÔ±ãÔÚJavaScriptÖÐʵÏÖ“¼Ì³Ð”µÄЧ¹û¡£
& ......
javaScript
ÖÐµÄ call
() ÊÇÒ»¸öÆæÃîµÄ·½·¨£¬µ«Ò²ÊÇÒ»¸öÈÃÈËÃÔ»óµÄ·½·¨£¬ÏÈ¿´Ò»Ï¹ٷ½µÄ½âÊÍ£º
call
·½·¨
Çë²ÎÔÄ
Ó¦ÓÃÓÚ£ºFunction ¶ÔÏó
񻂗
°æ±¾ 5.5
µ÷ÓÃÒ»¸ö¶ÔÏóµÄÒ»¸ö·½·¨£¬ÒÔÁíÒ»¸ö¶ÔÏóÌæ»»µ±Ç°¶ÔÏó¡£
call
([thisObj[,arg1[, arg2[, [,.argN]]]]])
²ÎÊý
thisObj
¿ÉÑ¡Ïî¡£½«±»ÓÃ×÷µ±Ç ......
<script language="javascript">
function newRow()
{
var tbl = document.all("mytbl");
var row = &nb ......
String.prototype.Trim=function(){
returnthis.replace(/(^\s*)|(\s*$)/g,"");
}
String.prototype.LTrim=function(){
returnthis.replace(/(^\s*)/g,"");
}
String.prototype.RTrim=function(){
returnthis.replace(/(\s*$)/g,"");
} ......