Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

presence of object

Status
Not open for further replies.

nurkht

Programmer
Joined
Jul 10, 2000
Messages
2
Location
RU
How can I check for presence of a object on a page ?
Thanks.
Vitaly
 
If by object you mean a named button, text field, image, etc. then here is one way...
Code:
<html>
<body>
<input type=button id=btnDemo>
</body>
<script language=&quot;javascript&quot;>
 var chk1 = document.all.btnDemo;
 var chk2 = document.all.btnNoExist;

 alert(&quot;btnDemo: &quot; + chk1 + &quot;\nbtnNoExist: &quot; + chk2)

 if (chk2 != &quot;[object]&quot;)
  alert(&quot;The object doesn't exist&quot;);
 else
  alert(&quot;Found object&quot;);
</script>
</html>

Hope it helps, Rob
robschultz@yahoo.com
-Focus on the solution to the problem, not the obstacles in the way.-
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top