How does js set div not to be displayed in an iframe frame



<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title> test </title>
<script language="javascript" type="text/javascript">

function getStyle() {

if (window.top == window.self) {

document.getElementById("top").style.display = 'block';

} else {

document.getElementById("top").style.display = 'none';


}

}
</script>

</head>
<body onload="getStyle();">
<form id="form1" runat="server">
<div id="top">
 Does not show in the framework, normal access display
</div>
</form>
</body>
</html>

Div top is displayed when the current page is accessed normally

The page does not display div top when the current page is in the iframe