You are targeting an iframe element with x. With these lines…
var y = (x.contentWindow || x.contentDocument);
if (y.document)y = y.document;
…what you are doing is accessing the iframe’s document
object and storing it on the y
variable. The two ways you can access an iframe’s document
object is by x.contentWindow.document
or directly via x.contentDocument
.
Older IE browsers don’t support contentDocument
directly, so they only support it via contentWindow.document
. This code tries to account for that with the if statement where it checks if y.document
(basically x.contentWindow.document
) exists or not. If it does, then ensure y
is set to it. If this statement fails for some reason, the y
is set to x.contentDocument
from the earlier line.
With that said, the if statement is unnecessary afaict. The code can be written as:
var y = (x.contentWindow.document || x.contentDocument);
This ensures whichever part of the condition evaluates to true is what gets set to y 
