By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
464,282 Members | 1,275 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 464,282 IT Pros & Developers. It's quick & easy.

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

P: n/a
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!
Jul 23 '05 #1
Share this Question
Share on Google+
3 Replies

P: n/a
On 8 Sep 2004 12:33:49 -0700, Russell wrote:
src="<%= request.getParameter("url")%>"


It is best not to mix Java code
into a post that is about JS.

A static HTML with the JS keeps everyone
focused and on the same 'page'.

It can also (sometimes) reveal the underlying
problem simply by unentangling the disparate
technologies involved.

...Just a thought for future posts.

Now, since I have no further ideas on the
solution, I will bow out of this thread
and leave it to the experts.

--
Andrew Thompson
http://www.PhySci.org/ Open-source software suite
http://www.PhySci.org/codes/ Web & IT Help
http://www.1point1C.org/ Science & Technology
Jul 23 '05 #2

P: n/a
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
Jul 23 '05 #3

P: n/a
Randy Webb <Hi************@aol.com> wrote in message news:<J6********************@comcast.com>...
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.
Jul 23 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.