5 Easy JavaScript Computer Tricks
July 26, 2017

JavaScript Computer Tricks

Programming tricks are some of the most amazing computer tricks.

And the important part is:

These tricks will serve as addition to your programming knowledge.

Explained below are 5 JavaScript Computer Tricks.


Number One

Mouse-Over Prompt

Do you know what a mouse-over is?

If you don’t, it is simply what will happen when you put the cursor of your mouse on a picture or text.

What I want to do is this:

I want a text box to show whenever the mouse is on a particular text.

And this text box should display some text.

I know you have seen such a thing before but:

You will see how it is done here and now.

Try it.

Open notepad on your computer and paste the code below into notepad.

Save the notepad document as pcmoment.html

Go to wherever you save the document with your web browser.

Drag your mouse to here What Is The Domain Name Of This Site?

You can also put it into your existing HTML code.

<div style=”text-align:center”>
<table style=”width:40%”>
<td align=”right”><a href=”” onmouseover=”alert(‘pcmoment.com’)”> What Is The Domain Name Of This Site?</a></td>

JavaScript Computer Tricks

Number Two

JavaScript Computer Trick To Display Alert Prompt

The purpose of this trick is to show you’re the idea behind an alert prompt works.

What you will do here is this:

Type some words into the box below and click Show it.

The box that appeared is the alert box.

<div style=”text-align:center”>
<textarea cols=”30″ name=”text” rows=”3″></textarea>
<div style=”text-align:center”>
<input onclick=”alert(this.form.text.value)” type=”button” value=” Show it!”>
<input name=”cancel” type=”reset” value=”Clear Prompt”>


Number Three

JavaScript Computer Trick To Display Letter by letter scroll

This is my favourite.

It will display the text like as if someone is typing it.

One after the other.

See how it works here

Copy the code into notepad and try it.

<p id=”scroller”></p>

<script type=”text/javascript”>

// Original: Pun Man Kit mkpunnl@netvigator.com

function scroll(position) {

var msg = ” Hello, please share pcmoment.com with your friends. Thanks “;

var out = “”;

var sc = document.getElementById(“scroller”);

for (var i=0; i < position; i++){

out += msg.charAt(i);


out += msg.charAt(position);

sc.innerHTML = out;


if (position != msg.length) {

window.setTimeout(function() { scroll(position); }, 50);


else {

window.setTimeout(function() { scroll(0); }, 2000);






Number Five

JavaScript Computer Trick To Display Random Quotes

The final trick and also an interesting one.

Have you open a page and see a quote on the page but…

… when you reload, or revisit that page you will see another quote?

It is the work of this javascript computer trick.

It is simple.

Just copy the code, paste into you existing code or notepad.

Also, you edit or remove the quotes and put the ones you like.

<script type=”text/javascript”>

//store the quotations in arrays

quotes = [];

authors = [];

quotes[0] = “I have a new philosophy. I’m only going to dread one day at a time.”;

authors[0] = “Charles Schulz”;

quotes[1] = “Reality is the leading cause of stress for those in touch with it.”;

authors[1] = “Jack Wagner”;

quotes[2] = “Few things are harder to put up with than the annoyance of a good example.”;

authors[2] = “Mark Twain”;

quotes[3] = “The pure and simple truth is rarely pure and never simple.”;

authors[3] = “Oscar Wilde”;

quotes[4] = “There’s no business like show business, but there are several businesses like accounting.”;

authors[4] = “David Letterman”;

quotes[5] = “Man invented language to satisfy his deep need to complain.”;

authors[5] = “Lily Tomlin”;


//calculate a random index number

index = Math.floor(Math.random() * quotes.length);


//display the quotation


document.write(“<DT>” + “\”” + quotes[index] + “\”</DT>\n”);

document.write(“<DD>” + “– ” + authors[index] + “</DT>\n”);





Number Five: The Ultimate List Of Computer Tricks

Finally, Check Out: