There is A large page named "B" and "c", "B" and "c. The content in c should be changed every time in the menu, but some js files are useful only on pages where c content is changed. Therefore, I wanted to write them in c1, c2, c3, c4, but it cannot be found in it. Later, it can only be written in. however, if some menus are rarely used in this way, page A will be very large, because it is filled with the introduced js. I tried n methods, but none of them worked. Later I wanted to load the required js into the page without clicking the menu, but I just put it in c1, c2, c3, c4... I still can't find it, and then I dynamically put it in the head of A, and then I can find it. Let's solve this problem first.
Function changeRight (url, updateDiv ){
LoadJs (url)
Var url = url;
Var pars = "";
Var myAjax = new Ajax. Updater (updateDiv, url, {method: 'get', parameters: pars });
}
Function loadJs (url ){
Var tmp = url. split ("/");
Var tmpNode;
For (var I = 1; I <tmp. length; I ++ ){
If (I = 3 ){
TmpNode = tmp [3]
}
// Alert (tmpNode );
VaR num = tmpnode. indexof (". Do ");
Tmpnode = tmpnode. substring (0, num );
// Alert (tmpnode );
VaR ohead = Document. getelementsbytagname ('head'). Item (0 );
VaR oscript = Document. createelement ("script ");
Oscript. type = "text/JavaScript ";
Oscript. src = ".../../JS/" + tmpnode + ". js ";
VaR tmpvalue = Document. getelementbyid ("flagtmp"). value;
// Alert (tmpvalue );
If (tmpvalue. indexof (tmpnode) =-1 ){
Document. getelementbyid ("flagtmp"). value = Document. getelementbyid ("flagtmp"). Value + "-" + tmpnode;
// Alert ("does not exist! "+ Document. getElementById (" flagtmp "). value +" ------ "+ tmpvalue. indexOf (tmpNode ));
OHead. appendChild (oScript );
}
Else {
// Alert ("already exists ");
}
}
}