http://www.myexception.cn/HTML-CSS/858757.html 在html页面中显示html代码,可以用textarea(效果不好看)、xmp(已经被取消了) 转换后可以用span显示了
【系统描述】:
function over(obj) { $(".tooltips").show(); $(".desc").html( HTMLEnCode($(obj).attr("t") != "" ? $(obj).attr("t") : "无")); var theScrollTop = document.body.scrollTop || document.documentElement.scrollTop; x = obj.offsetLeft; y = obj.offsetTop; document.getElementById("tools").style.left = (parseInt(x)) + "px"; document.getElementById("tools").style.top = (parseInt(y) - theScrollTop + 10) + "px"; } function HTMLEnCode(str) { var s = ""; if (str.length == 0) return ""; s = str.replace(/&/g, ">"); s = s.replace(//g, ">"); s = s.replace(/ /g, " "); s = s.replace(/\'/g, "'"); s = s.replace(/\"/g, """); s = s.replace(/\n/g, "
"); return s; } function HTMLDeCode(str) { var s = ""; if (str.length == 0) return ""; s = str.replace(/&/g, "&"); s = s.replace(/</g, ""); s = s.replace(/ /g, " "); s = s.replace(/'/g, "\'"); s = s.replace(/"/g, "\""); s = s.replace(/
/g, "\n"); s = s.replace(/'/g, "\'"); return s; }