HTML DOM Object form Property


The HTML DOM Object form property returns the reference of enclosing form for <object> element.

Following is the syntax −

Returning reference to the form object

ObjectElement.form

Let us see an example of Object form property

Example

 Live Demo

<!DOCTYPE html>
<html>
<head>
<title>HTML DOM Object form</title>
<style>
   form {
      width:70%;
      margin: 0 auto;
      text-align: center;
   }
   * {
      padding: 2px;
      margin:5px;
   }
   input[type="button"] {
      border-radius: 10px;
   }
</style>
</head>
<body>
   <form id="Home Page">
      <fieldset>
         <legend>HTML-DOM-Object-form</legend>
         <object id="objSelect" height="200" data="https://www.tutorialspoint.com/java8/images/java-   8-mini-logo.jpg"></object>
         <input type="button" onclick="getObjectForm()" value="Get location of pic in website">
         <div id="divDisplay"></div>
      </fieldset>
   </form>
<script>
   var divDisplay = document.getElementById("divDisplay");
   var objSelect = document.getElementById("objSelect");
   function getObjectForm() {
      divDisplay.textContent = 'Location of above picture: '+objSelect.form.id;
   }
</script>
</body>
</html>

Output

Before clicking ‘Get location of pic in website’ button −

After checking ‘Get location of pic in website’ button −

Updated on: 25-Oct-2019

154 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements