Monday 1 June 2015

JavaScript Alert

The simplest thing to do in JavaScript is quite probably doing an alert. To refresh your memory making an alert is this:

alert("Thing you want to alert")

You could add a 'window.' to the beginning of that, but you don't have to. It is very simple.

By comparison, to instead put your string into a paragraph of your site it requires    

document.getElementById("ID").innerHTML = "Thing you want to place";

Now, that I'm experienced and I might want to get an element by its ID for reasons other than changing its innerHTML, it doesn't seem that complicated, but for the life of me when I was starting out I couldn't remember that code for the life of me. Honestly, I would rather have created a canvas, and used

ctx.fillText("Test to be filled", arbitrary number, arbitrary number);

 So alert(), very useless, very annoying, very easy.

No comments:

Post a Comment