Here is one such demo
1.htm
Code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Untitled Document</title>
<script type="text/javascript">
var correct = true;
</script>
</head>
<body>
<iframe frameborder="0" height="250" width="500" src="2.htm" scrolling="auto"></iframe>
</body>
</html>
2.htm
Code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Untitled Document</title>
<script type="text/javascript">
if(typeof parent.window.correct === "undefined"){
location.href = "1.htm";
}
</script>
</head>
<body>
<h1>If you are viewing then you are viewing it in an iframe</h1>
</body>
</html>
There are two different files 1.htm and 2.htm. 2.htm file is supposed to be view only through an iframe via the 1.htm file.
Now open 1.htm file in browser you'll be able to view the content of 2.htm in the iframe. Now try to open 2.htm in your browser window, the page will be redirected to 1.htm and as a result the user can view the content of 2.htm only through an iframe.
This is just a demo from which you can achieve what you want.
Hope this helps
Bookmarks