Forum Moderators: open
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
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
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
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
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.
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.
I didn't know you could change a title after page load. I agree with Tedster, thanks for the enlightenment.
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