vi 替换

:%s/some/other/g

%表示所有行
g表示替换所有

解决“错误 768: 因为加密数据失败连接尝试失败”问题

原因是ipsec服务没启动,在services.msc里设置一下

手机客户端中文测试

从手机客户端测试中文是否正常,本文通过手机客户端发表

中文ok,哈哈

理解 JavaScript 闭包

http://www.cn-cuckoo.com/2007/08/01/understand-javascript-closures-72.html

上网本Win7PE里面硬盘安装win2003

按照网上pe安装2003的教程
1.格式化C盘
2.运行/i386/winnt32.exe /syspart:c
重启出现”a disk read error occurred press ctrl+alt+del to restart”

经过多番搜索,boot.ini里面引导文件用的是$WINNT~BT$里面的BOOTSECT.DAT
win7pe里可能做成让它找bootmgr了,遂想到把bootsect改回/nt52,结果失败

然后想到直接用win7的bootmgr,按照硬盘安装win7的教程里说的,拷贝bootmgr、/boot/boot.sdi、/boot/bcd到C盘根目录,重启,OK进去安装界面。

homeip.me 新建zone有问题

新建zone内有创建db文件

想起来了,是named目录权限的问题

javascript 面向对象

定义一个类似java类:
//一个类,也是一个构造函数
// The constructor for our ‘Lecture’
// Takes two strings, name and teacher
function Lecture( name, teacher ) {
// Save them as local properties of the object
this.name = name;
this.teacher = teacher;
}
//添加原型函数,即类生成的对象拥有的方法
// A method of the Lecture class, used to generate
// a string that can be used to display Lecture information
Lecture.prototype.display = function(){
return this.teacher + ” is teaching ” + this.name;
};
//又是一个类,包含一个lectures数组
// A Schedule constructor that takes in an
// array of lectures
function Schedule( lectures ) {
this.lectures = lectures;
}
//增加一个原型函数,作用是遍历lectures数组
// A method for constructing a string representing
// a Schedule of Lectures
Schedule.prototype.display = function(){
var str = “”;
// Go through each of the lectures, building up
// a string of information
for ( var i = 0; i < this.lectures.length; i++ )
str += this.lectures[i].display() + " ";
return str;
};
定义一个类似java对象:
// 用类生成对象
// Create a new Schedule object and save it in
// the variable 'mySchedule'
var mySchedule = new Schedule([
// Create an array of the Lecture objects, which
// are passed in as the only argument to the Lecture object
new Lecture( "Gym", "Mr. Smith" ),
new Lecture( "Math", "Mrs. Jones" ),
new Lecture( "English", "TBD" )
]);
// DOM 树需要加载完才能操作
// We can't manipulate the DOM until the document
// is fully loaded
window.onload = function(){
// Find all the

  • elements in the document
    var li = document.getElementsByTagName(“li”); //getElementsByTagName也是DOM标准里的方法
    // and add a ared border around all of them
    for ( var j = 0; j < li.length; j++ ) {
    li[j].style.border = “1px solid #000″; //style操作语法
    }
    // Locate the element with an ID of ‘everywhere’
    var every = document.getElementById( “everywhere” );
    // and remove it from the document
    every.parentNode.removeChild( every ); //parentNode和removeChild都不熟
    };
    //先建立空对象,再给它增加属性
    // Set obj to an empty object
    var obj = new Object();
    // objRef now refers to the other object
    var objRef = obj;
    // Modify a property in the original object
    obj.oneProperty = true;
    // We now see that that change is represented in both variables
    // (Since they both refer to the same object)
    alert( obj.oneProperty === objRef.oneProperty );
    // 数组传递引用
    // Create an array of items
    var items = new Array( “one”, “two”, “three” );
    // Create a reference to the array of items
    var itemsRef = items;
    // Add an item to the original array
    items.push( “four” );
    // The length of each array should be the same,
    // since they both point to the same array object
    alert( items.length == itemsRef.length );

    // 改变引用
    // Set items to an array (object) of strings
    var items = new Array( “one”, “two”, “three” );
    // Set itemsRef to a reference to items
    var itemsRef = items;
    // Set items to equal a new object
    items = new Array( “new”, “array” );
    // items and itemsRef now point to different objects.
    // items points to new Array( “new”, “array” )
    // itemsRef points to new Array( “one”, “two”, “three” )
    alert( items !== itemsRef );

    // String是值传递
    // Set item equal to a new string object
    var item = “test”;
    // itemRef now refers to the same string object
    var itemRef = item;
    // Concatenate some new text onto the string object
    // NOTE: This creates a new object, and does not modify
    // the original object.
    item += “ing”;
    // The values of item and itemRef are NOT equal, as a whole
    // new string object has been created
    alert( item != itemRef );

    方法重载和类型检查
    // 通过判断arguments的长度来重载
    // A simple function for sending a message
    function sendMessage( msg, obj ) {
    // If both a message and an object are provided
    if ( arguments.length == 2 )
    // Send the message to the object
    obj.handleMsg( msg );
    // Otherwise, assume that only a message was provided
    else
    // So just display the default error message
    alert( msg );
    }

    // 任意长参数,直接操作arguments,就实现了java的不定长参数了
    // A function that takes any number of arguments and makes
    // an array out of them
    function makeArray() {
    // The temporary array
    var arr = [];
    // Go through each of the submitted arguments
    for ( var i = 0; i < arguments.length; i++ ) {
    arr.push( arguments[i] );
    }
    // Return the resulting array
    return arr;
    }

    //typeof操作符
    function displayError( msg ) {
    // Check and make sure that msg is not undefined
    if ( typeof msg == ‘undefined’ ) {
    // If it is, set a default message
    msg = “An error occurred.”;
    }
    // Display the message
    alert( msg );
    }

    // 用typeof确定对象类型
    // Check to see if our number is actually a string
    if ( typeof num == “string” )
    // If it is, then parse a number out of it
    num = parseInt( num );
    // Check to see if our array is actually a string
    if ( typeof arr == “string” )
    // If that’s the case, make an array, splitting on commas
    arr = arr.split(“,”);

    //用constructor确定对象类型
    // Check to see if our number is actually a string
    if ( num.constructor == String )
    // If it is, then parse a number out of it
    num = parseInt( num );
    // Check to see if our string is actually an array
    if ( str.constructor == Array )
    // If that’s the case, make a string by joining the array using commas
    str = str.join(‘,’);

    // 用constructor来做类型限定
    // Strictly check a list of variable types against a list of arguments
    function strict( types, args ) {
    // Make sure that the number of types and args matches
    if ( types.length != args.length ) {
    // If they do not, throw a useful exception
    throw “Invalid number of arguments. Expected ” + types.length +
    “, received ” + args.length + ” instead.”;
    }
    // Go through each of the arguments and check their types
    for ( var i = 0; i < args.length; i++ ) {
    //
    if ( args[i].constructor != types[i] ) {
    throw “Invalid argument type. Expected ” + types[i].name +
    “, received ” + args[i].constructor.name + ” instead.”;
    }
    }
    }
    // A simple function for printing out a list of users
    function userList( prefix, num, users ) {
    // Make sure that the prefix is a string, num is a number,
    // and users is an array
    strict( [ String, Number, Array ], arguments );
    // Iterate up to ‘num’ users
    for ( var i = 0; i < num; i++ ) {
    // Displaying a message about each user
    print( prefix + “: ” + users[i] );
    }
    }

    // 变量作用域
    最外面都是window的变量,全局变量
    函数里面可以直接访问全局变量,varname,window.varname
    函数里面var声明的变量是局部变量

    //一个函数返回一个新的函数
    // A function that generates a new function for adding numbers
    function addGenerator( num ) {
    // Return a simple function for adding two numbers
    // with the first number borrowed from the generator
    return function( toAdd ) {
    return num + toAdd
    };
    }
    // addFive now contains a function that takes one argument,
    // adds five to it, and returns the resulting number
    var addFive = addGenerator( 5 );
    // We can see here that the result of the addFive function is 9,
    // when passed an argument of 4
    alert( addFive( 4 ) == 9 );

    //匿名函数使内部变量隐藏起来,不和外部变量冲突
    (function(){
    // The variable that would, normally, be global
    var msg = “Thanks for visiting!”;
    // Binding a new function to a global object
    window.onunload = function(){
    // Which uses the ‘hidden’ variable
    alert( msg );
    };
    // Close off the anonymous function and execute it
    })();

    继承:

  • JavaScript一起学之五:详解“0级DOM”——Document对象的属性和方法

    转自:http://hi.baidu.com/howlking/blog/item/cb75d6b4e2e146748bd4b240.html

    img_autoproxy.js

    function img_autoproxy(){
    	var imgs = document.images;
    	for(var i=0;i<imgs.length;i++){
    		imgs[i].onerror=function(){
    			if(this.src.indexOf('browse.php?u')==-1)
    			this.src=myParseURL(this.src);
    		}
    	}
    }

    js判断IE浏览器

    最短的,IE8同样有效

    if("\v"=="v")

    参考

    http://www.kuqin.com/webpagedesign/20090131/33551.html

    http://ajaxian.com/archives/ievv

    http://www.thespanner.co.uk/2009/01/29/detecting-browsers-javascript-hacks/