I am using a Classic ASP file (language = JavaScript) to display some HTML information. What I want to do is check if the page is in a frame, and if not, redirect to another page. Is there a way of checking if a page has a parent in Classic ASP? I’ve tried using window, but it isn’t recognised. The code should be something like this:
<%@ language = "JavaScript"%>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="content-type" content="text/html;charset=utf-8" />
<title>Secure Area</title>
<link href="css/basic.css" rel="stylesheet" type="text/css" media="all" />
<%
if (!window.parent)
window.location.replace("index.html");
%>
<link href="Images/FavIcon.ico" rel="shortcut icon" type="image/x-icon" />
</head>
</html>
Not really.
Browsers do not send information about frame structure to the server when they request a resource.
You could check the HTTP Referer header (it is optional so it might not be defined), make an HTTP request (using your server side code) back to that URI, then parse it to see if it contains any frames, and if any of them default to
src="your uri"or if any links targetting a frame havehref="your uri"… but that would be very inefficient and unreliable.This sort of thing is better handled with client side JS.