Javascript Computer Tricks

Edit Websites in Browser (Live)

Using this trick, you will be able to edit any webpage live in your browser as if it was a Wiki and change the details according to your wish.

use the following bookmarklets by dragging them to your Bookmarks bar.

Edit This Website

javascript:document.body.contentEditable%20=%20’true’;%20document.designMode=’on’;%20void%200

Done Editing

javascript:document.body.contentEditable%20=%20’false’;%20document.designMode=’off’;%20void%200

You can edit Google or even Facebook for that matter right in your browser and that too without requiring any technical know-how

Mouse over prompt

A mouse over allows you to prompt the person when their mouse is over a particular link or picture; great for letting someone know what a picture is, if the image is small.

<div style=”text-align:center”>

<table style=”width:40%”>

<tr>

<td align=”right”><a href=”” onmouseover=”alert(‘Created by PC Moment’)”>Who created this?</a></td>

</tr>

</table>

</div>

Your own prompt

Crate a prompt of any inputted text to learn how the JavaScript alert function works and what a prompt looks like in your browser.

<form>

<div style=”text-align:center”>

<p>

<textarea cols=”30″ name=”text” rows=”3″></textarea>

</p>

</div>

<div style=”text-align:center”>

<p>

<input onclick=”alert(this.form.text.value)” type=”button” value=”Say it!”>

<input name=”cancel” type=”reset” value=”Clear Prompt”>

</p>

</div>

</form>

Letter by letter scroll

Below, the message “There is Hope – Computer Hope” should display, letter by letter.

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

<script type=”text/javascript”>

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

function scroll(position) {

var msg = ” Hello, Share bctop1auto.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;

position++;

if (position != msg.length) {

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

}

else {

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

}

}

scroll(0);

</script>

Random quotes

<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(“<DL>\n”);

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

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

document.write(“</DL>\n”);

//done

</script>

Leave a Comment