if(self!=top){ window.open(self.location,'_top'); }
Can someone explain this?
EDIT
What does self!=top and window.open(self.location,'_top') mean respectively?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
This will break out of a HTML frame and replace the top-level frame by the current page.
It’s akin to clicking a link with
target="_top"set which will throw away the complete frameset and replace it with the page that link points to. It’s exactly what that code does by simply “opening a link” (in user terms; in JavaScript it takes the form ofwindow.open) to the very same page we’re seeing, but at the top level.selfin this respect is the page we’re currently in.topis the top-level frame the browser is displaying. If the browser doesn’t display a frameset, thenself == topholds. If however, our page is framed, then they will be different.So
self != topdetects if the page is displayed in a frame andwindow.openis, as noted before, just like clicking on a link with thetargetattribute set to"_top"(the second argument.