Webフロントエンドの知識点:要約2


1、マウスはページの中の任意のラベルをクリックして、alertこのラベルの名前
document.οnclick=function(e){
  e=e||window.event;
  var o=e.srcElement||e.target;
  alert(o.tagName);
}

互換性の問題:
1)e=e||window.event;イベント処理時にIEと他のブラウザイベントオブジェクトを区別する際によく使われる書き方
2)IE下はsrc Element,FF下はtargetである.
2、非同期ロードjs方案
1)script要素を動的に書き込む
document.write("");

2)script のsrc を に する
document.getElementById("script").src = "xxxx.js";

3、stringオブジェクトを に し、 のスペースを する
String.prototype.trim = function(){
	return this.replace(/^\s+|\s+$/g,"")
}