Copy Code code as follows:
function IsWindow (obj)
{
if (typeof obj.closed = = ' undefined ') return false;
var result =/\[object (Window|global) \]/i.test (Object.prototype.toString.call (obj));
if (result) return result;
try{
obj.closed = obj.closed;
return false;
}catch (e)
{
result = true;
}
return result;
}
function isdocument (obj)
{
if (typeof obj.body = = ' undefined ') return false;
var B = obj.body;
try{
Obj.body = null;
Obj.body = b;
return false;
}catch (e)
{
return true;
}
}
function Iselement (o)
{
var tn = ' TagName ', temp = O[tn],result;
if (typeof temp = = ' undefined ') return false;
try{
O[TN] = null;
result = (temp = = O[tn]);
O[TN] = temp;
return result;
}catch (e)
{
return true;
}
}
function Getownerwindow (node)
{
if (IsWindow (node)) return node;
var doc = isdocument (node)? Node:node.ownerDocument;
return Doc.view | | DOC.PARENTWINDIW | | Doc.defaultview;
}
Need to be fully tested