Jump to content

User:Pemaksa/Modularize.js

From Wikipedia, the free encyclopedia
Note: After saving, you have to bypass your browser's cache to see the changes. Google Chrome, Firefox, Microsoft Edge and Safari: Hold down the ⇧ Shift key and click the Reload toolbar button. For details and instructions about other browsers, see Wikipedia:Bypass your cache.
function createLink(text,url) {
	var newLink = document.createElement('a');
	newLink.setAttribute('href', url);
	newLink.appendChild(document.createTextNode(text));
	return newLink;
}

function createMenu() {
	var menu = document.getElementById('menu');
	var items = [
		{
			t:'Home',
			u:'index.html'
		},
		{
			t:'Sales',
			u:'sales.html'
		},
		{
			t:'Contact',
			u:'contact.html'
		}
	];
	for(var i = 0; i < items.length; i++) {
		var item = createLink(items.t, items.u);
		item.className = 'menu-item';
		menu.appendChild(item);
	}
}