JavaScript

JavaScript把数字转换为字符

具体方法

1,This conversion-through-concatenation feature of JavaScript results in an idiom that you may occasionally see: to convert a number to a string, simply add the empty string to it:

var n_as_string = n + "";

2,To make number-to-string conversions more explicit, use the String( ) function:

var string_value = String(number);

3,Another technique for converting numbers to 更多 >

JavaScript字符串中的转义序列值

表面上看没什么作用 但是如果一个单引号里面出现这种情况就只有这么办了!

'You\'re right, it can\'t be a quote'

那么JavaScript的转义序列到底有哪些了

 JavaScript 转义序列 序列 代表的字符 \0 NULL 字符(\u0000). \b 退格符 (\u0008). \t 水平制表符 (\u0009). \n 换行符(\u000A). \v 垂直制表符 (\u000B). \f 换页符(\u000C). \r 回车符(\u000D). \" 双引号 (\u0022). \' 单引号或撇号(\u0027). \\ 反斜线符号(\u005C). \xXX The Latin-1 character specified by the two hexadecimal digits XX. \uXXXX The Unicode character specified by the four hexadecimal 更多 >

使用XMLHttpRequest详解

使用 XMLHttpRequest 仅仅3个步骤而已:

  • 1,Creating an XMLHttpRequest object
  • 2,Specifying and submitting your HTTP request to a web server //指定http并向一个web server提交
  • 3,Synchronously or asynchronously retrieving the server’s response //同步或异步获取服务器响应

1,创建一个XMLHttpRequest object

大部分浏览器可以用

var request = new XMLHttpRequest();

Prior to Internet Explorer 7, IE does not have a native XMLHttpRequest() constructor function. In IE 5 and 6

var request = 更多 >

JavaScript将中文转化为utf-8编码

没有多复杂 就一个escape(string)便可

DIV仿IFRAME 效果代码

 

点击链接 查看效果 DIV仿IFRAME

指定div来createElement

function addDiv(){
        for(i=1;i< =5;i++){
          listdiv = document.getElementById('songslist');
          var newElement = document.createElement('div');
          var newText = document.createTextNode(i+" "+"haha");
          document.body.appendChild(newElement);
          newElement.id = i;
          if(i%2 == 0)
          {
            newElement.className = 'newDivClass';
          }else{
            newElement.className = 'newDivClass2';
          }
          newElement.setAttribute('name ','newDivName');
          newElement.style.lineHeight = '25px';
          newElement.style.textIndent = '24';
          newElement.style.width = '490px';
          newElement.style.height = '24px';
          newElement.style.margin = '0 auto';
          newElement.appendChild(newText);
          var newA = document.createElement("a");
          newA.href = "#";
          newA.title = "从播放列表里删除该歌曲!";
          newA.innerHTML = "删除"+i;
          newA.index_no = i;
          newElement.appendChild(newA);
          listdiv.appendChild(newElement);
        }
      }
更多 >

prototype.js常用函数和用法

函数名 解释 举例 Element.toggle 交替隐藏或显示 Element.toggle(”div1”,”div2”) Element.hide 隐藏 Element.hide(”div1”,”div2”) Element.show 显示 Element.show(”div1”,”div2”) Element.remove 删除 Element.remove(”div1”,”div2”) Element.getHeight 取得高度 Element.getHeight(”div1”) Toggle.display 和Element.toggle相同 Toggle.display(”div1”,”div2”) Insertion.Before 在DIV前插入文字 Insertion.Before(”div1”,”my content”) Insertion.After 在DIV后插入文字 Insertion.After(”div1”,”my content”) Insertion.Top 在DIV里最前插入文字 Insertion.Top(”div1”,”this is a text”) Insertion.Bottom 在DIV里最后插入文字 Insertion.Bottom(”div1”,”this is a text”) PeriodicalExecuter 以给定频率调用一段JavaScript PeridicalExecutor(test, 1)”这里test是Javascript的函数,1是频率(1秒). $ 取得一个DIV, 相当于getElementById() $(”div1”) Field.clear 更多 >

JavaScript 跳转代码

按钮式:


链接式: 返回上一步 

返回上一步 

直接跳转式:      

window.open 只能同时只能打开一个窗口

window.open(YourUrl,'_blank')

一直忘了参数 _blank