Forum Moderators: open

Message Too Old, No Replies

Can't get an onload event for iframes on Mac

How do I detect whether the iframe content is changed?

         

AWildman

3:24 pm on May 8, 2003 (gmt 0)

10+ Year Member



I have an intranet site that uses iframes. At the top of the container page is a history of how the user got to whatever page he/she is on. To make matters complicated, I have to allow for pages to be listed under multiple categories. I developed a nice menuing system that accounts for all this. It is contingent on knowing when a page has loaded into the iframe to change the history when the forward or back buttons on the toolbar are used. No, I'm not allowed to open the intranet in a toolbarless window.
My problem is that IE on the Mac won't give me any indication of when the iframe content changes. Normally this isn't a problem since I have control over 99% of the site's pages and can add an onload event to them. But for that 1%, I can't add the onload so IE on the Mac won't update the history at the top of the container page for those pages when navigation is done through the toolbar. I've tried everything:
1. Sticking the onload into the iframe tag
2. On the container page load, I've tried attaching an event listener for the iframe.
3. I tried putting script after the iframe in the container page to let me know when the iframe is loaded. That only fires once and I need to know every time.
4. I tried putting an onunload on the pages I can control.
5. I tried the <script for>

Argh! Thanks in advance for any help

tedster

9:59 pm on May 13, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Wow, this does sound like an impasse. I've been thinking about it on and off since you posted, and I come up empty.

If I understand you correctly, this problem only affects your IE/Mac users, and even for them, the issue is only for a few of the possible pages that they might load into the iframe. Still, something's hanging out and I know how that feels.

Anyone have an idea?

ShawnR

3:42 pm on May 14, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I have a suggestion: How about in the container page, instead of

<a href="some_page.htm" target="my_iframe">

you do:

<a href="my_cgi_script.cgi?page=some_page.htm" target="my_iframe">

Write a perl script (my_cgi_script.cgi) which reads "some_page.htm" and then outputs that page, but with the <body> tag modified to include your onload="..."

Shawn

AWildman

4:01 pm on May 14, 2003 (gmt 0)

10+ Year Member



Well, that would be a great idea except that the pages that I can't touch generally aren't html pages. They are word docs or the login to our calendar system. I was thinking about going the perl route this morning. I just don't know how it would work to write a script that would keep track of every time the iframe content changed.
The sad part is, if I could just find the stinkin' event for ie on the mac, I'd have it made cause I already have the code to check the history.
I also tried checking the readystate and setting it to onload if it changed, etc., but that only fired once as well. I thought it was my last brightest hope. Maybe it is still a possibility, but I just didn't get the javascript right. Any thoughts on the feasibility of using the onreadystate combined with event.onload to make a workaround?
I may just give up. :-0 It will be a sad, sad day.
By the way, thanks for the ideas. You guys are the best!

ShawnR

4:11 pm on May 14, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Hows this for an ugly hack: Set a timer and have the event handler of your timer read the url of the iframe every second or so.

Shawn

AWildman

4:22 pm on May 14, 2003 (gmt 0)

10+ Year Member



Now THAT is an ugly hack. However, I may have to get real ugly with this issue soon. :)
<rant>For the love of God and all that is holy, why didn't the Mac IE people think about my problems when they programmed?! Couldn't they have foreseen this issue? Just goes to prove that the Microsoft folks aren't as infallible as we all thought.</rant> (Okay that last bit was more sarcasm than rant)

AWildman

7:31 pm on May 14, 2003 (gmt 0)

10+ Year Member



WAHOO! I fixed my problem and the solution was right under my nose.
Now, granted, this is NOT the way I wanted to do it, but it works and since I know that someone else will eventually want to do this, I'll post the fix.
Instead of linking to the end page which I cannot touch, I link to a page that contains an iframe that has an src set to the link of the page I can't change.
Basically, the container page has a link that targets its iframe, and the iframe now has a document within it that has an iframe containing the untouchable page.
To try and streamline the process, I'm going to see about making one iframe page for all nonchangeable pages to be viewed through, then add a variable to the url when linking to this page that will update the location of the iframe. That way, I don't have to make an iframe page for each of the pages that I can't change.
I've been agonizing over this forever and the solution was soooo simple...

ShawnR

2:17 am on May 13, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Well done!

I assume that the pages you are linking to don't have links to other pages.

Shawn

AWildman

3:59 pm on May 14, 2003 (gmt 0)

10+ Year Member



You know, sometimes just writing or talking about the problem helps the creative juices to flow! :)
No, they don't have links. They are mostly standalone word docs and pdfs.