Forum Moderators: open

Message Too Old, No Replies

How to change browser title with framed forwarding?

         

may_hem1

11:04 pm on Aug 19, 2003 (gmt 0)

10+ Year Member



Hiya, I've just bought a domain name from Easily.co.uk and am using framed forwarding (cloaking) to point that domain to some free Web space that I get with my Blueyonder broadband.

The problem is that the browser title contains the basic domain name, because that's what Easily's forwarding page contains. They won't let me change the contents of that forwarding page without buying hosting from them.

So how can I change the browser title?

Obviously, the <TITLE> tags in my site are ignored as my site's pages are contained within Easily's frame. So I thought JavaScript might help. I tried putting this in the head of my HTML page:

<script>
<!--
document.title='Welcome to my Web site';
//-->
</script>

Unfortunately, this doesn't change the browser's title text.

Any ideas on how I can fix this?

Thanks,
May

MonkeeSage

12:13 am on Aug 20, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Hi there May,

You have the right idea, but you need to set the parent's document.title since your site appears in an iframe / frame. :)

<script type="text/javascript">
<!--
void(parent.document.title='Welcome to my Web site');
//-->
</script>

Also, setting the document.title attribute returns it's value (for some strange reason), so you should wrap it in a void(), which will nullify anything returned by it. This isn't essential for newer browsers, though w/o it some of the older ones might interpret it as HTML and make your page a blank page with just the title written on it. ;)

Jordan

may_hem1

12:38 am on Aug 20, 2003 (gmt 0)

10+ Year Member



Thanks for your suggestion Jordan, but unfortunately it doesn't work.

Strange thing is that I put the following code into the head of my main 'index.html' page and it doesn't work when you view the site using the purchased domain name, but it does work when I type in the long URL for my Blueyonder Web space:

<script>
<!--
if (opener) {
alert('there is an opener');
}
else
{
alert('the title is: ' + top.document.title);
}
void(parent.document.title='Welcome to my Web site');
//-->
</script>

I.e. I don't get an alert at all when I type the purchased domain name into a browser, but I do get an alert when I type in the free Web space URL directly.

This is strange as all that Easily have in their forwarding Web page is a FRAME tag pointing to the free Web space URL.

Any ideas on how to fix this?

Thx,
May

MonkeeSage

12:49 am on Aug 20, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



May:

Hmmm...wierd. Mabye they have some server side scripting set up to persist their own title or something. But even at that you should be seeing the alerts as you said. Very wierd.

I can only think of a couple other things to try...
-Try setting the type attribute on the script tag.
-Try putting the whole script block inside the body -- just after the opening tag or just before the ending tag.

Other than that I have no idea.

Ps. If nobody else has any suggestions, or you want to, you can sticky me the URL and mabye I can help figure out what is going on.

Jordan

tedster

2:07 am on Aug 20, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I really appreciate this conversation. I never before thought about changing the frameset title from within the loaded frame, but I have one spot on a client's site where it makes perfect sense.

I used Jordan's javascript and it works perfectly in that situation. So I agree, it seems like there must be something the host is doing server-side to prevent the script from working.

gph

2:21 am on Aug 20, 2003 (gmt 0)

10+ Year Member



I don't think js can access a document from a different domain. Unfortunately the only solution I think you have is paying for hosting.

You could pay for a minimum amount of space and get creative with absolute urls. Things like linking to images or using iframes for content that reside on your free space.

MonkeeSage

2:27 am on Aug 20, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



gph:

You are absolutely correct -- cross-domain access to iframes / frames is a no-no. I didn't even think that my tests were using two pages on the same domain, and May's are on two different domains. Doh!

Jordan

gph

2:44 am on Aug 20, 2003 (gmt 0)

10+ Year Member



I played with this for a bit as well until I remembered reading about issues with setting the height of an iframe depending on the source. It boiled down to having to have the iframe source on the same domain as the parent.

I didn't know you could change a title after page load. I agree with Tedster, thanks for the enlightenment.

gph

2:53 am on Aug 20, 2003 (gmt 0)

10+ Year Member



To clarify, may_hem1 didn't want to change the title after page load but I tried it and it worked. For some reason I had it in my head that that was a security no-no as well.

MonkeeSage

5:32 am on Aug 20, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



gph:

I did too...I thought I remembered getting 'tried to set an attribute that only has a getter' errors when I tried setting document.title awhile back, so I had not tried it again until today. Learn something new every day. :)

Jordan

may_hem1

2:00 pm on Aug 20, 2003 (gmt 0)

10+ Year Member



Hi, thank you all for your thoughts.

So I can't change the top frame title because it's not from my domain?

I guess I'm stuck with Easily's choice of browser title?

I suppose that's better than the horrible URL that Blueyonder offer me.

May

MonkeeSage

2:09 pm on Aug 20, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Might be possible yet, with PHP or other server side scripting. You should see if your free account has PHP or Perl or any other CGI (Computer Gateway Interface) support, and if they do, see what you can see using what they support.

Jordan

may_hem1

12:15 am on Aug 21, 2003 (gmt 0)

10+ Year Member



Hi Jordan, I'm a little confused what you mean. How could server-side solve this?

If browsers don't allow cross-domain interference then what could PHP etc do to remedy this?

Thanks,

May

MonkeeSage

5:05 am on Aug 21, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



May:

It's not the browsers that don't allow it, its the JavaScript implementation (I think). If there is a way to set the same objects as JavaScript, server side may not have the security restriction at this particular point. It was just a thought...I don't know any server side at all, though, so mabye I was just wistling out of my ear.

Jordan

ShawnR

2:29 pm on Aug 21, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I'm with may_hem1 on this. Server side scripting on the framed page can't have any effect on the framing page.