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(inParent){
if (window.opener.document.getElementById(theVal) != null) {
return true;
} else {
return false;
}
}else{
if (document.getElementById(theVal) != null) {
return true;
} else {
return false;
}
}
}

Note:
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.

16 Replies to “Check whether an HTML element/Object exists or not.”

  1. Pingback: Buy Phentermine
  2. Realy first time i am viewing this site . it is realy very cool and nice website which are providing valuable solution and guide. Most thing i get here realy it praising.Related Article ,Tips are good describing and very clear. You are guys are realy have dine very well.

  3. Realy first time i am viewing this site . it is realy very cool and nice website which are providing valuable solution and guide. Most thing i get here realy it praising.Related Article ,Tips are good describing and very clear. You are guys are realy have done very well.

  4. It works! BTW Firefox says malware is hosted on this site! It said thesafety1.co.cc, so it’s probably an iframe…?

Leave a Reply to ashutosh bhardwaj Cancel reply

Your email address will not be published. Required fields are marked *