user1692342
user1692342

Reputation: 5237

Change main window title to that of iframe title

I am building a node webkit application and I would like my window title to be same as that of the title of the iframe. My iframe title keeps changing regularly (on receiving a notification). I would like my main window title also to keep track of that change and update its own title.

I extract the title of the iframe with this command with Jquery: $("#app").contents().find("title").text() where #app is the ID of the iframe

Upvotes: 1

Views: 1541

Answers (2)

Dom Slee
Dom Slee

Reputation: 611

Maybe something like this:

newTitleListener = SetInterval(CheckForNewTitle, 200)

oldTitle = '';
function CheckForNewTitle(){
    newTitle = $("#app").contents().find("title").text();
    if (newTitle != oldTitle){ //Set the new title
        document.title = newTitle;
        oldTitle = newTitle;
    }
}

Upvotes: 2

Sourabh Kumar Sharma
Sourabh Kumar Sharma

Reputation: 2827

it is as simple as putting the below code in your iframe

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

Upvotes: 1

Related Questions