Google Answers Logo
View Question
 
Q: "Problem with pages in a frame that uses _top" ( Answered,   0 Comments )
Question  
Subject: "Problem with pages in a frame that uses _top"
Category: Computers > Programming
Asked by: sonici-ga
List Price: $10.00
Posted: 14 Oct 2003 05:51 PDT
Expires: 13 Nov 2003 04:51 PST
Question ID: 266063
How can i browse a page in a frame that uses _top ,knowing that using
_top makes my frame disappear?

Request for Question Clarification by joseleon-ga on 14 Oct 2003 06:10 PDT
Hello, sonici:
  Can you preprocess the page before put it on the frame?

Regards.

Clarification of Question by sonici-ga on 15 Oct 2003 08:04 PDT
No i cant preprocess the page before i puted in the frame

Clarification of Question by sonici-ga on 15 Oct 2003 08:06 PDT
is there a way i can have control on the page from the frame and make changes?

Request for Question Clarification by joseleon-ga on 15 Oct 2003 11:13 PDT
Hello, sonici:
  I don't think so, because this would mean a security issue in the
browser, I'm going to make some little tests.

Regards.

Request for Question Clarification by joseleon-ga on 18 Oct 2003 08:40 PDT
Hello, sonici:
  I have been researching what you want, and the only way I think it
can be done it's by preprocessing the page in the server by changing
all links to remove "_top" targets and to point to the preprocessor to
start all over again.

By the way, here are some articles that maybe are useful to you:

Q126 How would I be able to force all incoming pages to appear within
the specified frame (many pages have _top or _parent target
parameters)?
http://developer.irt.org/script/126.htm

This question redirects to an article:

Re-directing access within Frames
http://tech.irt.org/articles/js013/index.htm

And there is a new version of the article here:

Re-directing access within Frames #2
http://tech.irt.org/articles/js126/index.htm

If you are interested in a server solution (i.e. PHP), please, let me
know.

Regards.

Clarification of Question by sonici-ga on 18 Oct 2003 13:14 PDT
Hi joseleon,
With Preprocessing I want to know how much it will cost me if many
users enters my site.
I want also to know the speed of preprocessing.
Thanks alot

Request for Question Clarification by joseleon-ga on 19 Oct 2003 23:29 PDT
Hello, sonici:

  Preprocessing it's just a matter of:
  -In the server, get the contents of a page
  -Process the links
  -Dump out the processed page

It's like you were serving the external website instead the user
browsing it. Also, tell you that you must have permission from the
external website to place the content on your website.

Regards.

Request for Question Clarification by joseleon-ga on 25 Oct 2003 01:16 PDT
Hello, sonici:
  Are you still interested in an answer?

Regards.

Clarification of Question by sonici-ga on 25 Oct 2003 07:31 PDT
yes give it to me with full explanation plz

Request for Question Clarification by joseleon-ga on 25 Oct 2003 08:43 PDT
Hello, sonici:
  Ok, so let's imagine, the page you want to get into a frameset is
something like this:
  
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html;
charset=iso-8859-1">
</head>

<body>
<p>This page uses target=_top to jump outside any frame set</p>
<p>&nbsp;</p>
<p><a href="target_top.htm" target="_top">Click here to eliminate
framesets</a> </p><p>Won't work if you clicked in the Processed Link
on the left<p>
</body>
</html>

Please, not the link here:

<a href="target_top.htm" target="_top">

As you can see, the target is "_top", which will erase any frameset
once the user clicks that link, to remove that attribute from the link
before the page is shown to the browser, you can use the following PHP
script:

<?php
  include "class.BrowserEmulator.php";
	
  $be = new BrowserEmulator(); 
	
  $base=$_GET['base'];
  $page=$_GET['page'];

  $file = $be->fopen($page); 

  echo "<base href=\"$base\">";

  while ($line = fgets($file, 1024)) 
  {
    $pos=strpos($line,'target="_top"');
    if ($pos === false) 
    {
      //Do nothing
    }
    else
    {
      $line=str_replace('target="_top"','',$line);
    }

    echo $line;
  } 
  fclose($file); 
?>

This script can be called this way:

scriptname.php?base=http://www.yourserver.com/&page=http://www.yourserver.com/target_top.htm

And will load the target_top.htm page, and will parse it erasing any
target="_top" that finds, after that, will output the page, so if the
user clicks on any link, it won't go out of the frameset.

I have not posted the code of the class.BrowserEmulator.php, nor a
sample, because before post an answer I want to be sure that this is
what you are looking for. I mean, you can use that script to parse any
page you want and modify any contents of it before be echoed to the
clients browser. So if this is what you want, please, let me answer
the question and I will post the full source code and a sample.

Also, this is one page solution, if you want to browse a full site
into a frameset, this will require a more sofisticated solution, but I
think this is outside the scope of this question.

Regards.

Clarification of Question by sonici-ga on 28 Oct 2003 06:11 PST
yes plz give me the source code
Answer  
Subject: Re: "Problem with pages in a frame that uses _top"
Answered By: joseleon-ga on 28 Oct 2003 11:32 PST
 
Hello, sonici:
  You can download the full sources from here:
  
  http://www.qadram.com/target_top.zip
  
  This zip file contains the following files:
  
  browse_test.php
  An example on how to use the BrowserEmulator to get, parse and dump
out a page
  
  class.BrowserEmulator.php
  The Browser itself
  
  target_top.htm
  The page that contains a link with target="_top"
  
  frameset.htm
  A sample frameset to test the browse_test.php script
  
  leftframe.htm
  The left frame of the frameset, contains two links, a plain link
that loads directly target_top.htm and another one that calls
browse_test.php
  
  mainframe.htm
  The initial main frame
  
Please, don't hesitate to request any clarification on this sample,
I'm here to help you.

Regards.
Comments  
There are no comments at this time.

Important Disclaimer: Answers and comments provided on Google Answers are general information, and are not intended to substitute for informed professional medical, psychiatric, psychological, tax, legal, investment, accounting, or other professional advice. Google does not endorse, and expressly disclaims liability for any product, manufacturer, distributor, service or service provider mentioned or any opinion expressed in answers or comments. Please read carefully the Google Answers Terms of Service.

If you feel that you have found inappropriate content, please let us know by emailing us at answers-support@google.com with the question ID listed above. Thank you.
Search Google Answers for
Google Answers  


Google Home - Answers FAQ - Terms of Service - Privacy Policy