How to Disable the browsers’ back button

You can Disable the browsers’ back button if you want to prevent your users to go back for some reasons like the registration page or for some pages once they are submitted should not be reversed back, which might lead into unwanted problems .

There is a little hack to achieve this, you can use the following js code.


Close Window in IE from javascript. (Small Hack)

When trying to close an window from javascript in IE, which is opened manually,
a security warning “The web page you are viewing is trying to close the window. Do you want to close this window? Yes|No ” is popping up. Is there any possibility to close a window silently? Yes.

A simple hack i found on the web will help to get rid of this situation.

self.opener = this;

but in Firefox you can do this. Firefox will not allow you to close using the above code. Maybe anybody found/having any code post it here.

How to find your Popup is blocked by Popup blocker in javascript

How to find your Popup is blocked by Popup blocker in javascript when using

We open a window using in our pages using javascript. But if there is popup blocker sitting in the client machine and the user is not aware the popup blocker is blocking the popup window from your site, we can inform him the popup is blocked and ask him to remove that. How?'yourfile.htm' + "?newwin=true", "_top", "width="+wwidth+",height="+wheight+",location=0,menubar=0,resizable=no,scrollbars=no,status=yes,titlebar=no,dependent=yes");
alert("Error: While Launching New Window...nYour browser maybe blocking up Popup windows. nn  Please check your Popup Blocker Settings");

How to Change an image’s width dynamically from Javascript

How to Change an image’s width dynamically from Javascript. Using DOM we can do this.

function changeImgSize(objectId,newWidth,newHeight) {
imgString = 'theImg = document.getElementById("'+objectId+'")';
oldWidth = theImg.width;
oldHeight = theImg.height;
theImg.width = newWidth;
theImg.height = newHeight;

Note: this one i found on the web but i can’t remember where i found. Credits to the author.

Check whether an HTML element/Object exists or not.

This small javascript function will help you to check if a HTML object.Element exists in a page from the page itself or from a popup window.

function chkObject(inParent,theVal) {
if (window.opener.document.getElementById(theVal) != null) {
return true;
} else {
return false;
if (document.getElementById(theVal) != null) {
return true;
} else {
return false;

chks whether an object exists or not in the document.
if the inParent is true then the object/elt is checked for its existence in the parent/opener’s document.
i.e., it will be useful to chk from a popup window.
To check in the current document itself , then set inParent value as false.

To load an doc inside a iframe dynamically

We can load a document into an iframe dynamically by using iframe.src = “yourpage” in javascript.
But this works well in IE and not in others browsers. Here is an method to load iframes dynamically.

I found this at and just changed something to fit our need.

var IFrameObj;
function loadIFrame(thePage){
//loads an doc inside a iframe dynamically
URL = thePage;
IFrameObj = new Object();
IFrameObj.document = new Object();
IFrameObj.document.location = new Object();
IFrameObj.document.location.iframe = document.getElementById('cpaneif');
IFrameObj.document.location.replace = function(location) {
this.iframe.src = location;

if (navigator.userAgent.indexOf(‘Gecko’) !=-1 && !IFrameObj.contentDocument) {
// allow a fraction of a second to recognize the new IFrame
//return false;

if (IFrameObj.contentDocument) {
// For NS6
IFrameDoc = IFrameObj.contentDocument;
} else if (IFrameObj.contentWindow) {
// For IE5.5 and IE6
IFrameDoc = IFrameObj.contentWindow.document;
} else if (IFrameObj.document) {
// For IE5
IFrameDoc = IFrameObj.document;
} else {
return true;

/* NB:-
//if you want to create a new iframe dynamically visit