Timing Issue - Setting Title of IFrame Modal Dialog Window Using the Contained Window Title

Discussion in 'Javascript' started by Russell, Sep 8, 2004.

  1. Russell

    Russell Guest

    I have a quirky issue that I believe involves timing and only 2 hairs left to pull.

    I have a modal dialog that is an IFrame.
    The IFrame contains another window - which contains the appropriate title.

    I am trying to change the title of the IFrame window to be
    that of the contained window title.

    If I uncomment the alert statement below - the title change works.
    Comment out the alert - and - no title change.

    I have unsuccessfully tried using the following
    methods/events as timing devices:
    setTimeout, onload, onreadystatechange

    The problem appears to be that I have to make the title change
    before the modal window is displayed - which I cannot seem to capture.

    ANY assistance is greatly appreciated...

    Start of code sample:
    ....
    <body>
    <iframe id="content"
    name="embeddedContent"
    src="<%= request.getParameter("url")%>"
    frameborder="0"
    height="100%"
    width="100%">
    </iframe>
    </body>
    <script language="javascript">
    var myIframe = document.getElementById("content");

    if (myIframe)
    {
    if(myIframe.contentWindow)
    {
    //alert("stop now");
    if(myIframe.contentWindow.document)
    {
    document.title = myIframe.contentWindow.document.title;
    }
    }
    }
    </script>
    ....

    End of code sample

    Thanks!
    Russell, Sep 8, 2004
    #1
    1. Advertising

  2. Russell

    Randy Webb Guest

    Re: Timing Issue - Setting Title of IFrame Modal Dialog Window Usingthe Contained Window Title

    Russell wrote:

    > I have a quirky issue that I believe involves timing and only 2 hairs left to pull.
    >
    > I have a modal dialog that is an IFrame.
    > The IFrame contains another window - which contains the appropriate title.
    >
    > I am trying to change the title of the IFrame window to be
    > that of the contained window title.
    >
    > If I uncomment the alert statement below - the title change works.
    > Comment out the alert - and - no title change.
    >
    > I have unsuccessfully tried using the following
    > methods/events as timing devices:
    > setTimeout, onload, onreadystatechange
    >
    > The problem appears to be that I have to make the title change
    > before the modal window is displayed - which I cannot seem to capture.
    >
    > ANY assistance is greatly appreciated...
    >
    > Start of code sample:
    > ....
    > <body>
    > <iframe id="content"
    > name="embeddedContent"
    > src="<%= request.getParameter("url")%>"
    > frameborder="0"
    > height="100%"


    onload="setTitle()"

    > width="100%">
    > </iframe>
    > </body>
    > <script language="javascript">


    <script type="text/javascript">
    function setTitle(){


    > var myIframe = document.getElementById("content");
    > if (myIframe)
    > {
    > if(myIframe.contentWindow)
    > {
    > //alert("stop now");
    > if(myIframe.contentWindow.document)
    > {
    > document.title = myIframe.contentWindow.document.title;
    > }
    > }
    > }


    }

    Use the onload of the IFrame tag to call the function, and then wrap
    your script in a function.

    Tested in Mozilla, IE and Opera.

    --
    Randy
    comp.lang.javascript FAQ - http://jibbering.com/faq
    Randy Webb, Sep 8, 2004
    #2
    1. Advertising

  3. Russell

    Russell Guest

    Randy Webb <> wrote in message news:<>...
    > Russell wrote:
    >
    > > I have a quirky issue that I believe involves timing and only 2 hairs left to pull.
    > >
    > > I have a modal dialog that is an IFrame.
    > > The IFrame contains another window - which contains the appropriate title.
    > >
    > > I am trying to change the title of the IFrame window to be
    > > that of the contained window title.
    > >
    > > If I uncomment the alert statement below - the title change works.
    > > Comment out the alert - and - no title change.
    > >
    > > I have unsuccessfully tried using the following
    > > methods/events as timing devices:
    > > setTimeout, onload, onreadystatechange
    > >
    > > The problem appears to be that I have to make the title change
    > > before the modal window is displayed - which I cannot seem to capture.
    > >
    > > ANY assistance is greatly appreciated...
    > >
    > > Start of code sample:
    > > ....
    > > <body>
    > > <iframe id="content"
    > > name="embeddedContent"
    > > src="<%= request.getParameter("url")%>"
    > > frameborder="0"
    > > height="100%"

    >
    > onload="setTitle()"
    >
    > > width="100%">
    > > </iframe>
    > > </body>
    > > <script language="javascript">

    >
    > <script type="text/javascript">
    > function setTitle(){
    >
    >
    > > var myIframe = document.getElementById("content");
    > > if (myIframe)
    > > {
    > > if(myIframe.contentWindow)
    > > {
    > > //alert("stop now");
    > > if(myIframe.contentWindow.document)
    > > {
    > > document.title = myIframe.contentWindow.document.title;
    > > }
    > > }
    > > }

    >
    > }
    >
    > Use the onload of the IFrame tag to call the function, and then wrap
    > your script in a function.
    >
    > Tested in Mozilla, IE and Opera.


    Thank you but... I tried adding the onload to the iframe and it still
    did not work. However - after several days of searching (four to be
    exact)- I did find another way to handle my problems. The reason I
    was using an iframe was because everyone told me I needed to when
    using a modal dialog that posted back to itself. The modal window
    would actually open up a new window instead of posting back to itself.
    Several places on the internet and some internal employees all told
    me I had to use an iframe. After 4 wasted days of struggling through
    trying to get the title (with no luck might I add) I happened upon
    someone's single line of code solution - <base target="_self">.
    I got rid of the iframe - and have no problems whatsoever. I have my
    titles and my window is posting to itself rather than opening a new
    one - so life is
    good again.

    Thank you all who responded - any and all responses were greatly
    appreciated.
    Russell, Sep 13, 2004
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Guadala Harry
    Replies:
    0
    Views:
    2,652
    Guadala Harry
    Oct 3, 2004
  2. Matt
    Replies:
    1
    Views:
    3,127
    Whitecrest
    Jun 1, 2004
  3. Moshe Katz
    Replies:
    1
    Views:
    88
    Grant Wagner
    May 6, 2004
  4. Matt
    Replies:
    0
    Views:
    213
  5. gopal srinivasan
    Replies:
    0
    Views:
    220
    gopal srinivasan
    Nov 5, 2004
Loading...

Share This Page