Skip to content

Instantly share code, notes, and snippets.

@weemie
Created July 23, 2008 01:17
Show Gist options
  • Save weemie/1439 to your computer and use it in GitHub Desktop.
Save weemie/1439 to your computer and use it in GitHub Desktop.
basic.js
/**=========================================================
menu selected
----------------------------------------------------------*/
function ChangeSelected(id){
if(document.getElementById(id) != null){//IDの存在をチェック
//SideMenuの子供のA要素からhref属性の値を取得
var parentNode = document.getElementById(id);
var Tags = parentNode.getElementsByTagName("a");
for (var i = 0; i < Tags.length ; i++){
if(Tags[i].href==document.URL){//現在のURLとHREFの値が同じとき
//Aのclassを変更
if(Tags[i].parentNode.nodeName!="dd"){
Tags[i].className="active";
}
}
}
}
}
/**=========================================================
addLoadEvent
----------------------------------------------------------*/
function addLoadEvent(func){
var oldonload = window.onload;
if (typeof window.onload != 'function'){
window.onload = func;
} else {
window.onload = function(){
oldonload();
func();
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment