 |
|
|
| View previous topic :: View next topic |
| Author |
Message |
Karin
Joined: 27 Sep 2005 Posts: 3
|
Posted: Tue Sep 27, 2005 10:11 am ASP: Response.Redirect and Frames - Help Please! |
|
|
|
Hi, I have a website that was originally developed in frames and I can't change that.
I need to use Response.Redirect and target that to the same window but outside the frameset. How can I do that? |
|
piklemeup

Joined: 05 Jun 2005 Posts: 25 Location: Canada EH!
|
Posted: Sun Oct 02, 2005 6:41 pm |
|
|
|
i've seen web sites like this before. i have no idea (at the moment) how to do this. but try finding a site that does this and try taking it apart a bit. see how it works and how the link gets out of the frames... maybe link it to the index (or whatever page the frames are in). so pretend the 2 web pages are #1 and #2, #1 being the one that encases the frames, #2 being the page with the link on it. try linking page #2 to page #1... if that makes any sense at all. when i say link i mean open it in that page. so name the page whatever and link it to whatever the name is. and i completely forget how to do this at the moment.... sorry for not helping at all.  |
|
nsavalas

Joined: 16 Nov 2009 Posts: 4 Location: Los Angeles, CA US
|
Posted: Tue Nov 17, 2009 1:11 am How to keep a framed page in it's frameset, always... |
|
|
|
Dear Karin,
I must have answered this question 100 times on other help sites and groups, but it is amazing that I accidentally found your question almost five years after you first asked it, and no one at this website has answered it for you.
Before I answer, let me stress: NEVER USE FRAMES! Search engines cannot index your content properly, most mobile devices cannot use them at all, they make your site very hard to read for handicapped visitors, etc. Even though this code will validate with most doctypes (see: http://validator.w3.org/), I am telling you that using this code is the wrong answer; rewrite your site - do not use frames. Ever.
This code will allow you to use response.redirect to the actual and exact link you desire without using the now deprecated "target" attribute; the framed page itself will recover your frameset schema. The only downside is that your URL will be altered in the address bar. Aside from that, this code will do the job.
Let us assume that you have a page named index.htm (or .asp, or whatever), that has your logo, navigation, etc. Here is that page's code:
| Code: |
<html>
<head>
<title>Old Frameset</title>
</head>
<frameset rows="120,*">
<frame name="nav" target="content" src="nav.htm">
<frame name="content" src="1.htm">
<noframes>
<body>
<p>This page uses frames because I am a boob.</p>
</body>
</noframes>
</frameset>
</html> |
Then you have a navigation page at top (nav.htm), with some goofy code like:
| Code: |
<html>
<head>
<title>Navigation</title>
</head>
<body>
<p><a target="content" href="1.htm">1</a> - <a target="content" href="2.htm">2</a></p>
</body>
</html> |
The content frame below it is 1.htm to start, so it is something like:
| Code: |
<html>
<head>
<title>Page 1</title>
</head>
<body>
<p><a target="_self" href="2.htm">Go to page 2</a></p>
</body>
</html> |
...and so on. If you were ever lucky enough to actually find your page (1.htm) on a search engine, 1.htm would be without any navigation, and just be that lonely half-page.
Instead, let's change index.htm, our start page, to:
| Code: |
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML Basic 1.1//EN"
"http://www.w3.org/TR/xhtml-basic/xhtml-basic11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
<title>My less idiotic framed page</title>
<meta http-equiv="Content-Type" content="application/xhtml+xml; charset=utf-8" />
<meta name="keywords" content="frames, are, bad" xml:lang="en" />
<link rel="stylesheet" xml:lang="en" href="style.css" type="text/css" media="screen" />
</head>
<body id="body" class="body" title="page body" xml:lang="en">
<p><a href="index.htm">
<img src="logo.jpg" width="240" height="60" alt="My Logo" title="My Logo" />
</a></p>
<p><a href="1.htm">frame 1</a> - <a href="2.htm">frame 2</a></p> |
Now here's the trick: END THE PAGE WITH THIS BIT OF JAVASCRIPT:
| Code: |
<script type="text/javascript">
/* <![CDATA[ */
var curl = location.search.substring(1) ? unescape(location.search.substring(1)) : '1.htm';
document.writeln('<iframe src="'+curl+'" width="98%" height="480" style="border: 0px inset; padding: 0px" />');
/* ]]> */
</script>
</body>
</html> |
One last thing - on every page that needs to be set in a frame, add:
| Code: |
<script type="text/javascript">
if (self.location == top.location &&
location.search.substring(1) != 'nf')
top.location.href = 'index.htm?' + escape(self.location);
</script> |
When you go to look at: http://example.com/1.htm in a browser, you'll get instead...
http://example.com/index.htm?http%3A//example.com/1.htm
...but your page 1.htm will never be outside of it's frame. Good luck. I hope to hear from you soon. Until I do, Karin, I remain,
Sincerely Yours,
Nicholas Savalas - http://savalas.tv |
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|
|
|
|