Hi,
I have a question which is a little hard to explain, but here goes:
For the website i am developing, I will have a links section. When one of these links is clicked, i want the visited page to be a frame-system where the top frame displays my website logo and the bottom frame shows the requested webpage. This is very similar to Ask Jeeves, where clicking on one of the search results brings up a frame system where the bottom frame can be navigated whilst the top frame remain showing the logo. Writing a script to display thsi kind of frame system was simple enough, but here lies my problem: when a link on the requested page is clicked (i.e. the page in the bottom frame), the browser goes to that page and i lose my frame system! I thought a possible work-around for this (and this is where it gets difficult to explain) would be to first of all scan the requested page and change all the links to point back to my script. In this way, the link <a href="www.hotmail.com">Visit Hotmail</a> would turn into <a href="www.mydomain.com/myscript.php?query=www.hotmail.com>Visit Hotmail</a>. By referring each link to my script all the time means that if that link was selected, myscript.php could set up the frames system for this new page with my logo in the top frame and the requested page with altered links in the bottom frame. In this way, whenever the user clicked a link the frames system would be kept. I hope you got that. Basically what I'm saying is i'd like a system like Ask Jevves with the frames. I made some php to try and change the links (which i've pasted below) but it doesn't work! Anyone have any idea how to make it work or an alternative way of getting this frame-enabled browsing? Thanks for reading all this bore, hope someone can help me out.
Curtis
<?php
/
This script is meant to take a web adress, read the file into a variable
and then replace all hyperlinks within the page to a format of:
<a href="www.mydomain.com/thisphpscript.php?query=www.the-original-link-target.com">
The links are intended to point back to this script so that if a link
is clicked, this script will change all the links in the requested page
to point back to itself as well. In this way, the user can keep surfing within
a frame system, very similar to ASK JEEVES. The frame at the top can have logos
etc. whereas the user can surf through the bottom page and never lose the frame system.
/
##################################
//submitted info is $wadd (web address), the URL of the page to visit
//this address is the first part of the new URL in each page
$address="<a href=\"www.mydomain.com\/thisphpscript.php\?wadd=";
$file = fopen($wadd, r) or die ("Could not connect");
while ($line = fgets($file, 1024)) {
if (preg_match('/<a.href[[:space:]]?=[[:space:]]?["\']?(.?)["\'>]/i', $line, $array)) {
$newaddress = $address . $array[1] . ">";
$newstring = (eregi_replace('<a.href[[:space:]]?=[[:space:]]?["\']?(.?)["\'>]', $newaddress, $line));
$wholething .= $newstring;
}
}
echo $wholething;
?>