Results 1 to 5 of 5

Thread: force page to load in iframe?

  1. #1
    Join Date
    Mar 2009
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question force page to load in iframe?

    Hello,

    I am looking for a script that works.

    There seems to be so many on the interent some works and some dont.

    I thought i would post here as some i dont quite understand.

    Basically i have a page with an iframe that loads some webpages of mine in an iframe when user clicks on link in sidebar.

    Problem is user could easily type the url to the page in iframe and view it not in iframe this is a big issue specially if for example a user clicks on a iframe page link in google and it loads not in iframe as it could confuse the user.

    so basically i want a script that if user tries to load page outside the iframe it directs them to the iframe page and loads the webpage they requested in the iframe.

    If someone could help.

    thank you
    computerwiz

  2. #2
    Join Date
    Mar 2009
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    anyone please?

  3. #3
    Join Date
    Sep 2005
    Location
    India
    Posts
    1,627
    Thanks
    6
    Thanked 107 Times in 107 Posts

    Default

    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

  4. #4
    Join Date
    Apr 2009
    Posts
    39
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default

    Hey! I was looking for this trick ;o)

    But: when I open 2.htm it does, correctly, open 1.htm instead. But it opens 1.htm with the default *.htm site.

    My iFrame in 1.htm:
    <iframe name=target style="width:626px;height:531px" src="mainFrame.htm" allowtransparency="true" frameBorder=0></iframe>


    Now, i want to target 2.htm to the NAMED iFrame (target) in 1.htm... Is that possible?

  5. #5
    Join Date
    Apr 2009
    Posts
    39
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default

    hmmmm...is this thread closed for good?

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •