<html>
<body>
<form id="form1">
示例表单:<input type="text" name="exampleform">
</form>
<br>
<object id="myObject" data="/i/photo/tulip.jpg" width="300" height="300" name="obj1" form="form1"></object>
<p>点击按钮可显示 object 元素所属表单的 id。</p>
<button onclick="myFunction()">试一试</button>
<p id="demo"></p>
<script>
function myFunction() {
var x = document.getElementById("myObject").form.id;
document.getElementById("demo").innerHTML = x;
}
</script>
</body>
</html>