HTML JavaScript
Use a nearly identical piece of code in multiple web pages: function getAlist(alist){
Generate a tag based on alist
}
Called on each page
a page: getAlist(['a2','a3','a4]);
b page: getAlist(['a1','#','a3','a4]);
I don’t understand what you mean
If you generate a tag through js, you can use
var a=document.createElement("a");
a.id=.. .
a.href=...
a.innerHTML=...
You can try putting the content in a js object
Instead of generating it, it is better to control
function e(event){ var evt = event || window.event; var target = evt.target || evt.srcElement; window.location = target.id+".html";}/* @linkId : 不需要跳转的 A 元素 ID*/function setLinks(linkId){ var menus = document.getElementById("menus").getElementsByTagName("a"); for(var i=0; i< menus.length; i++){ if(menus[i].id.toLowerCase() != linkId.toLowerCase()){ if (window.attachEvent){ menus[i].attachEvent('click',e) }else if(window.addEventListener){ menus[i].addEventListener('click',e,false) } } } }window.onload = function(){ setLinks('a1');}