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

R

Russell

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!
 
R

Randy Webb

Russell said:
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.
 
R

Russell

Randy Webb said:
<script type="text/javascript">
function setTitle(){



}

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.
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,733
Messages
2,569,440
Members
44,830
Latest member
ZADIva7383

Latest Threads

Top