คุณสมบัติ HTML DOM Object form ส่งคืนการอ้างอิงของ form ที่ล้อมรอบสำหรับ <object> element
ไวยากรณ์ (Syntax)
การส่งคืนการอ้างอิงไปยังออบเจ็กต์ form:
ObjectElement.form
ตัวอย่างการใช้งาน
<!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>
ผลลัพธ์
ก่อนคลิก 'Get location of pic in website':

หลังตรวจสอบ 'Get location of pic in website':
