Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Javascript > Timing Issue - Setting Title of IFrame Modal Dialog Window Using the Contained Window Title

Reply
Thread Tools

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

 
 
Russell
Guest
Posts: n/a
 
      09-08-2004
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!
 
Reply With Quote
 
 
 
 
Randy Webb
Guest
Posts: n/a
 
      09-08-2004
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
 
Reply With Quote
 
 
 
 
Russell
Guest
Posts: n/a
 
      09-13-2004
Randy Webb <(E-Mail Removed)> wrote in message news:<(E-Mail Removed)>...
> 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.
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to close a parent modal window when child modal window opens? gopal srinivasan Javascript 0 11-05-2004 05:59 AM
Reload IFrame from Code Behind (when aspx opened as modal dialog) Guadala Harry ASP .Net 0 10-03-2004 08:38 PM
post the form data in modal window and close the modal window. Matt HTML 1 06-01-2004 08:22 PM
post the form data in modal window and close the modal window. Matt Javascript 0 06-01-2004 07:47 PM
Server name is being added in front of my modal dialog title on Win2003 Moshe Katz Javascript 1 05-06-2004 06:34 PM



Advertisments