yourbudweiser
asked on
IFRAME TARGET
I have a page with an iframe. In the iframe, when the user clicks a link, instead of the new page appearing in the iframe, surrounded by my graphics, the new page replaces the current page. This is becuase some of the links in the iframe have the target="_top" attribute. How can I prevent the links from clearing out my page without having to remove the target="_top" ?
ASKER
Jeff, thanks for responding. I checked out the websites you suggested... The first one, there are alot of links but I couldn't find one that would help me with my problem. I also looked throught the second link and although it had lots of tips for framed pages, none of them related to iframes that are stored on other servers. If you could suggest some ideas for a server side script that would do what I need, I would love to hear it, Thanks again, YBW
change the target name to the IFrame name
yourbudweiser, is there any a possibility that we can get some code snipits of what you currently have in place, and an explaination of your environment (platform, webserver, etc) as well as a list of the server-side languages you are familiar with? Something I probably should have mentioned above is that most of the rules that govern frames are the same rules you would apply to iframes (there are some exceptions), but for what you are trying to do it sounds like you simply need to change your target. Here are a few additional links pertaining to iframes that might prove useful:
http://developer.irt.org/script/1347.htm
http://developer.irt.org/script/1268.htm
http://developer.irt.org/script/333.htm
http://developer.irt.org/script/1648.htm
http://developer.irt.org/script/853.htm
http://developer.irt.org/script/1318.htm
Is there a particular reason you need to keep the target='_top' in place in your existing pages other than the fact that it might prove painful to make changes across your entire site? I'll be watching for your response.
Good Luck,
Jeff
http://developer.irt.org/script/1347.htm
http://developer.irt.org/script/1268.htm
http://developer.irt.org/script/333.htm
http://developer.irt.org/script/1648.htm
http://developer.irt.org/script/853.htm
http://developer.irt.org/script/1318.htm
Is there a particular reason you need to keep the target='_top' in place in your existing pages other than the fact that it might prove painful to make changes across your entire site? I'll be watching for your response.
Good Luck,
Jeff
ASKER
Hi Jeff, thanks for responding.
The page in the iframe is actually on another server which I have no control over. In the iframe page are links with the target=_top. When clicked the links open in a new window, outside of the iframe.
I cannot modify that page so I can't remove the target=_top and I can't modify it at all. Therefore, I need some other way to prevent the links target=_top from opening in a new window.
<iframe name="metro" src="http://metrotag.clickprint.com" height="600" width="820" border="0" frameborder="0"></iframe>
The web server is MS and I am familiar with ASP.
I'll be looking at the links you suggested also.
Thanks again,.
The page in the iframe is actually on another server which I have no control over. In the iframe page are links with the target=_top. When clicked the links open in a new window, outside of the iframe.
I cannot modify that page so I can't remove the target=_top and I can't modify it at all. Therefore, I need some other way to prevent the links target=_top from opening in a new window.
<iframe name="metro" src="http://metrotag.clickprint.com" height="600" width="820" border="0" frameborder="0"></iframe>
The web server is MS and I am familiar with ASP.
I'll be looking at the links you suggested also.
Thanks again,.
Hi,
This is funny, (well it is if you have PHP on your server).
frame.html
=======
<HTML>...
<iframe width="100%" height="100%" name="wibble" src="demo.php?url=http://metrotag.clickprint.com/"></ifra me>
...</HTML>
demo.php:
=======
<HTML>...
<?php
if (eregi("http://metrotag.clickprint.com/", $url))
{ echo "<!-- from the site -->"; }
else
{
echo "<BASE href=$url>";
}
$html = implode ('', file ($url));
$html= str_replace ("target=\"_top\"", " ", $html);
$html= str_replace ("href=\"", "href=\"demo.php?url=", $html);
echo $html
?>
...</HTML>
Lol, it breaks on the 'design online' flash detection with an invalid session, but it's fun until then.... If this were specifically for this site, we could get around that.. but, anyway - just for kicks.
If you have PHP on the server and it's just for this site, let me know which items break and we'll correct them. If it's to frame any site, this is probably not the answer..(especially if no PHP)...
Well, it was fun.. ;)
This is funny, (well it is if you have PHP on your server).
frame.html
=======
<HTML>...
<iframe width="100%" height="100%" name="wibble" src="demo.php?url=http://metrotag.clickprint.com/"></ifra
...</HTML>
demo.php:
=======
<HTML>...
<?php
if (eregi("http://metrotag.clickprint.com/", $url))
{ echo "<!-- from the site -->"; }
else
{
echo "<BASE href=$url>";
}
$html = implode ('', file ($url));
$html= str_replace ("target=\"_top\"", " ", $html);
$html= str_replace ("href=\"", "href=\"demo.php?url=", $html);
echo $html
?>
...</HTML>
Lol, it breaks on the 'design online' flash detection with an invalid session, but it's fun until then.... If this were specifically for this site, we could get around that.. but, anyway - just for kicks.
If you have PHP on the server and it's just for this site, let me know which items break and we'll correct them. If it's to frame any site, this is probably not the answer..(especially if no PHP)...
Well, it was fun.. ;)
ASKER
Hey dreamer, thanks for responding but i'm not into PHP so... can you do something similar in ASP? What is your trying to do there?
I'll have a play with it. I'm all on linux hosting and although theres a versoin of asp, it's just not 100%, so testing is a bit diff...
Here is the version - http://www.thisisyourname.com/demo/test.php
Have a look.
We take in the webpage as a string, parse it and change the target. It's then displayed on our own dynamic page and...well, it works. lol.
Hmm, *thinking of test environment for asp witout messing too much with IIS....*
d.
Here is the version - http://www.thisisyourname.com/demo/test.php
Have a look.
We take in the webpage as a string, parse it and change the target. It's then displayed on our own dynamic page and...well, it works. lol.
Hmm, *thinking of test environment for asp witout messing too much with IIS....*
d.
ASKER
dreamer, that works great! now if I can get it to work with ASP i'll be in your debt!
I'll work with it as well and looking foward to seeing your solution in ASP :-)
YourBudWeiser
Election 2004 Battleground State of Florida
I'll work with it as well and looking foward to seeing your solution in ASP :-)
YourBudWeiser
Election 2004 Battleground State of Florida
No problems - nearly done. I'll be out for an hour, will complete upon return..sry for delay. :)
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Hey dreamer, great job!
This problem was on my mind all day yesterday! With your help, I came up with the following last night:
page1.asp:
<iframe name="metro" src="includes/page2.asp?ur l=http://metrotag.clickprint.com/"></ifra me>
page2.asp:
<%
Function GetHTML(strURL)
Dim objXMLHTTP, strReturn
Set objXMLHTTP = Server.CreateObject("MSXML 2.ServerXM LHTTP")
objXMLHTTP.Open "GET", strURL, False
objXMLHTTP.Send
strReturn = objXMLHTTP.responseText
Set objXMLHTTP = Nothing
GetHTML = strReturn
End Function
newhtml = GetHTML(Request("url"))
newhtml = replace(newhtml, "target=""_top""", "")
newhtml = replace(newhtml, "href=""", "href=""page2.asp?url=")
response.write newhtml
%>
Thanks alot for sticking with this question, you were a great help!
YourBudWeiser
This problem was on my mind all day yesterday! With your help, I came up with the following last night:
page1.asp:
<iframe name="metro" src="includes/page2.asp?ur
page2.asp:
<%
Function GetHTML(strURL)
Dim objXMLHTTP, strReturn
Set objXMLHTTP = Server.CreateObject("MSXML
objXMLHTTP.Open "GET", strURL, False
objXMLHTTP.Send
strReturn = objXMLHTTP.responseText
Set objXMLHTTP = Nothing
GetHTML = strReturn
End Function
newhtml = GetHTML(Request("url"))
newhtml = replace(newhtml, "target=""_top""", "")
newhtml = replace(newhtml, "href=""", "href=""page2.asp?url=")
response.write newhtml
%>
Thanks alot for sticking with this question, you were a great help!
YourBudWeiser
and information on IFRAMEs/FRAMEs here: http://developer.irt.org/script/frame.htm
Hope that helps somewhat and Good Luck,
Jeff