Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to change window title from a frame in javascript?

I hosted my web app on a freehoster service which shows my webpage in a frameset. 2 frames are there. In the top narrow frame there are their ad and the bottom frame is mine. I can set the title in the admin panel but it always remains the same regardless what is in my title tag. Setting document.title in javascript not works. But if I break out from the frameset using the ff's This frame/show option it will change the window/tab title as expected.

So is it possible to change the parent document's title from my frame?

(background: it will be an ajax board game and I want to notify the user somehow when it's his turn.)

like image 795
Calmarius Avatar asked Jun 30 '10 14:06

Calmarius


People also ask

How do I change the title of a framed document?

Changing the Title of a Framed Document: The title shown is the title of the frameset document rather than the titles of any of the specified pages within frames. We need to link to a new frameset document in order to change the title displayed using the TARGET attribute.

How do I change my Windows title?

While holding down the Control key, click multiple windows commands to edit their window titles. Right-click on one of the selected commands, and click Change Window Title. In the Change Window Title dialog, specify a window title to replace the current selected window titles.

How do you make a title in JavaScript?

Put in the URL bar and then click enter: javascript:alert(document. title); You can select and copy the text from the alert depending on the website and the web browser you are using.


2 Answers

Yes, but it has to be on the same domain (and use a relative url for a path)

  window.parent.document.title = "Your new title";

If the iframe/frame is on a different domain, then you'll get a permission denied error.

like image 64
Dan Heberden Avatar answered Oct 07 '22 08:10

Dan Heberden


use top.document.title (top refers to the top most window within the browser)

like image 26
AlbertVanHalen Avatar answered Oct 07 '22 10:10

AlbertVanHalen