*a constant parallactic paradox, sublime*

Javascript: DOM, Window Object, Page Load and URL Encoding/Decoding Examples

This software ( is so good at omitting scripts from your post and it’s true that if you wanna benefit from the glory of it all use the actual product ( I do not have my own domain for that though, so in spite of the absence of an actual demonstration, here are some useful javascript source codes!

window element

This code shows how to display a popup window.

onclick="'test.html', 'windowname1', 'width=200, height=77'); return false;"
Full window properties
function popup(url) 
 var width  = 500;
 var height = 500;
 var left   = (screen.width  - width)/2;
 var top    = (screen.height - height)/2;
 var params = 'width='+width+', height='+height;
 params += ', top='+top+', left='+left;
 params += ', directories=no';
 params += ', location=no';
 params += ', menubar=no';
 params += ', resizable=no';
 params += ', scrollbars=yes';
 params += ', status=no';
 params += ', toolbar=no';,'windowname5', params);
 if (window.focus) {newwin.focus()}
 return false;


This code shows how to change the innerHTML value of a tag, change the color of a text, change the options of a select, make some page contents disappear, disable radio buttons, mark radio buttons as checked by default and basically how to user a switch function in JS and use the function getElementByID().

<script language="javascript">
function act(n){
		default: break;
		case 1:{
			document.getElementById("targetObj").innerHTML = 
"<p id='helloworld'>hello world</p>";
			replaceSelectOpt("change color of 'hello world'", 2);
		case 2:{
			document.getElementById("helloworld").style.color = "red";
			replaceSelectOpt("change me into useless radio buttons", 3);
		case 3:{
			r = "<input type='radio' name='rad' checked='true'>huhuhuh";
			r = r + "<input type='radio' name='rad' disabled='true'>nahnah";
			document.getElementById("thejester").innerHTML = r;
			s = "<a href='javascript:void(0)' onClick='act(4)'>
I am tired. Make me vanish.</a>";
			document.getElementById("helloworld").innerHTML = s;
		case 4:{
			document.getElementById('thejester').innerHTML = "";
			document.getElementById('targetObj').innerHTML = "";

function replaceSelectOpt(txt, nxt){
	full = "<option>Choose!</option><option onClick=
'act(" + nxt + ")'>" + txt + "</option>";
	document.getElementById("you_have_no_choice_but_to_follow").innerHTML = full;


<div id="thejester">
	<select id="you_have_no_choice_but_to_follow">
	<option onClick="act(1)">show me a paragraph</option>

<div id="targetObj"></div>

history.go() function

Go to previous page

For whatever purpose it may serve, you may use the history() function to navigate towards a specific page in your history.

Reload Page

escape() and unescape() functions //url encode and decode

These are the javascript counterparts for PHP’s rawurldecode and rawurlencode.

<input type="text" size="100" onKeyPress=
<div id="s"></div>

Jeassshhh… There’s too much code here….(X_+)


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s