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
Ïà¹ØÎĵµ£º
JavaScriptÀï×Ö·û´®ÀàÐÍת»»³ÉÈÕÆÚÀàÐÍ£º
Èç¹û×Ö·û´®ÖÐÓпոñ»òÊÇÆäËû·Ö¸î·û·Ö¸î£¬¿ÉÒÔÓÃsplit·½·¨ÏȲð·Ö£¬·µ»ØÒ»¸öÊý×飬ÔÙ°ÑÕâ¸öÊý×éÀïµÄÄêÔÂÈÕ×÷Ϊ²ÎÊý´«µ½new Date()ÀïÉú³ÉÈÕÆÚÀàÐÍ£»
Èç¹ýûÓÐÌØÊâ·Ö¸ô·û£¬¿ÉÒÔÓÃsubstr£¨x£¬y£©·½·¨À´È¡×Ó×Ö·û´®À´Éú³ÉÈÕÆÚ£¬substr£¨x£¬y£©Àx±íʾȡ×Ö´®µÄ¿ªÊ¼Î»Öã¬y±íʾ×Ó´®µÄ³ ......
HTMLÖÐʵÏÖÓÒ¼ü²Ëµ¥¹¦ÄÜ
ÎÒÃÇʹÓõÄÓ¦ÓÃϵͳºÜ¶à¶¼ÓÐÓÒ¼ü²Ëµ¥¹¦ÄÜ¡£µ«ÊÇÔÚÍøÒ³ÉÏÃ棬µã»÷ÓÒ¼üÒ»°ãÏÔʾµÄÈ´ÊÇIEĬÈϵÄÓÒ¼ü²Ëµ¥£¬ÄÇôÎÒÃÇÈçºÎʵÏÖ×Ô¼ºµÄÓÒ¼ü²Ëµ¥ÄØ£¿ÏÂÃ潫½²½âÓÒ¼ü²Ëµ¥¹¦ÄܵÄʵÏÖÔÀíºÍʵÏÖ´úÂë¡£
ʵÏÖÔÀí
ÔÚHTMLÓïÑÔÖУ¬»ù±¾ÉÏÿ¸ö¶ÔÏó¶¼ÓÐÒ»¸öoncontextmenuʼþ£¬Õâ¸öʼþ¾ÍÊÇÊó±êµÄÓÒ¼üµ¥»÷ ......
function QueryString(fieldName){
var urlString = location.search;
if (urlString != null) {
var typeQu = fieldName + "=";
var urlEnd = urlString.indexOf(typeQu);
if (urlEnd != -1) {
var paramsUrl = urlString.substring(urlEnd + typeQu.length);
var isEnd = paramsUrl.indexOf('&' ......
<script >
function showimage()
{
//IMG1ΪͼƬ¿Ø¼þ»òDiv,File1ΪÉÏ´«Îļþ¿Ø¼þ
document.getElementById("IMG1"). src = document.getElementById("File1").value;
}
</script >
¿Ø¼þÖÐÒýÓÃ:
<input id="File1" runat="server" type="file" onc ......
<script type="text/javascript">
function dayChange(year,month,day){
var selectYear = document.getElementById(year);
var selectMonth = document.getElementById(month);
var selectDay = document.getElementById(day);
va ......