instanceof关键字的疑问
大佬们,你看下我代码注释的部分,为什么第二个弹出的是false,而第四个弹出true,不是应该弹出的是true么?能指点一下么??我现在要判断无论是当前页面的document还是iframe的document都返回true怎么判断??
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>TEST</title> <script type="text/javascript"> window.onload = function () { var doc = document.getElementById("mainFrame").contentWindow.document; alert(doc); // 弹出 [object HTMLDocument] alert(doc instanceof HTMLDocument); // 弹出false alert(document); // 弹出 [object HTMLDocument] alert(document instanceof HTMLDocument); // 弹出true } </script></head><body> <iframe id="mainFrame" src="test1.htm"></iframe></body></html>