Use self to reference the current document : self « Language Basics « JavaScript Tutorial






<html>
<head>
<script language="JavaScript" type = "text/javascript">
<!--
if (top==self)
{
    var main_frame = "http://www.java2s.com";
    var cur_url = self.location.href;
    var setframes = main_frame + "?" + cur_url;
    location.href = setframes;
}
//-->
</script>
</head>
<body>

</body>
</html>








1.5.self
1.5.1.Use self to reference the current document