潘文斌个人博客
记忆不行,只能记录
记忆不行,只能记录
五 13th
按照网上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进去安装界面。
五 11th
定义一个类似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
// 改变引用
// 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
})();
继承:
五 10th
转自:http://hi.baidu.com/howlking/blog/item/cb75d6b4e2e146748bd4b240.html
五 10th
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); } } }