User:BoatsAreRockable/global.js

importScriptPage('PurgeButton/code.js', 'dev'); //create div document.body.onload = addElement; function addElement { // creates a div element, class and html content var new_div = document.createElement('div'); new_div.className = 'charlietools'; new_div.innerHTML = 'The html text content'; new_div.style.width = "100px"; new_div.style.height = "100px"; new_div.style.background = "red"; new_div.style.color = "white"; // gets the reference tag var existingelement = document.getElementById('WikiaPageHeader'); // add 'add_div' before 'existingelement', inside body document.body.insertBefore(new_div, existingelement;} document.body.onload = addElement;

function addElement { // create a new div element // and give it some content var newDiv = document.createElement("div"); var newContent = document.createTextNode("Hi there and greetings!"); newDiv.appendChild(newContent); //add the text node to the newly created div.

// add the newly created element and its content into the DOM var currentDiv = document.getElementById("div1"); document.body.insertBefore(newDiv, currentDiv); }