Search code examples
javascripthtmlcssframeframeset

Is there a way to change the title of index.html from page in the frame by using JavaScript?


Possible Duplicate:
How to change window title from a frame in javascript?

In my index.html file I have 3 frames.

I want to change the title of index.html from one of the pages in frames.

How could this be done by using JavaScript?


Solution

  • 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.

    If the above fails, use

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