Index Ask! Random

Question: Frames - How Do I Keep a Dynamic Address Bar?

I have a framed page, and I want to have the address bar of the browser change each time someone clicks a link in the frame. You said that if I want that, I should stop using frames. The problem is, even though I control both the framing page and the framed page, they are on different domains.

Could you give more detail about the "round robin" you talked about?

Answer

Why don't I do an example. Let's say you have a domain: a.com, and a domain: b.com. And the page a.com/framing.asp is a framing page, and it calls up a frame from the domain b.com (let's say b.com/1.asp).

Now, let's further suppose that the page b.com/1.asp has a link to b.com/2.asp . Unfortunately, when someone clicks that link, since it is a change of location within the frame, the address bar of the browser doesn't change. So here's what you do.


Find your hyperlink to the page: b.com/2.asp - it will look something like this:

<a href="2.asp">Click here to go to page 2</a>

Now change this hyperlink so it looks like this:

<a href="http://www.a.com/framing.asp?location=2" target="_top">Click here to go to page 2</a>

Notice that you are now sending your visitor back to the framing page on the first domain. Only now there is a query string: location=2. Also note that I've used the target="_top" parameter to escape the frame.

Now you just need to add a bit of script to your framing page:

Dim strFrameURL
select case request("location")
case "2"
strFrameURL="http://www.b.com/2.asp"
case else
strFrameURL="http://www.b.com/1.asp"
end select


Now you can use the variable strFrameURL to point your frame to the right location. You have essentially played "Round Robin" with your two domains - each hyperlink click sends the visitor back to domain A, which then returns them to the appropriate page on domain B.

It's round-about, but now every framed page has a distinct URL, which is what you were hoping for.

Bookmark and Share