Forum Moderators: open

Message Too Old, No Replies

Safari PHP iframes have an invalid id attribute: "photo frame" ?

         

JeanGenie

7:56 am on Aug 12, 2009 (gmt 0)

10+ Year Member



After much wrangling I found the weirdest issue I can ever recall:

A page with an iframe wasn't loading its src in Safari; though it was ok in Firefox, the Safari src was "about:blank".


<iframe class="mt_big mb_big" width="170" height="300" src="[my src file, removed here]" id="photo_frame" name="photo_frame" scrolling="no" style="border: 1px solid #000000;">
</iframe>

The src file loaded fine by itself in a tab, and validated at the W3C site.

So I kept deleting chunks of the code (a PHP page) and retesting; finally I had about a 10-line PHP file, with no actual PHP or Javascript or anything in it, with the iframe the only thing in the body. It still didn't work.

I copied this to an html file (test.html)... and it WORKED! Same exact file; the HTML version loaded the src while the PHP did not.

Finally narrowed it down to the id and name attributes of the PHP's iframe tag: if either is set to "photo_frame", it will not work.

I could not find a single mention of this anywhere on Google. My computer came within 5 minutes of being beaten with a baseball bat. Just wanted to post about it and ask if anyone else had heard of anything like this. I couldn't find information online about ANY reserved or invalid ids, Safari or otherwise.

I went back to the original, full PHP file, changed the id and name in the iframe to something else, and the src loads fine now.

Oh yeah, I tried (in the tiny PHP file):


<p id="photo_frame">Hello</p>

in the body instead of the iframe and it worked. It's only Safari, only PHP files, only iframe tags, and only "photo_frame" as name or id.

Sigh. How is any of this possible?

JeanGenie

12:43 pm on Aug 12, 2009 (gmt 0)

10+ Year Member



Ah.

Apparently, the problem is that Safari has a very aggressive cache for iframe src's. It doesn't cache actual contents, but stores the src value based on an iframe's id. Evidently I had the src blank while working on it, and since the iframe's id hadn't changed it was still using src="" even though I'd actually put something in the src.

I now change the iframe's id dynamically on each page load:

(PHP) <? $timestamp=time(); ?>

(HTML) <iframe id="photo_<?=$timestamp?>" [...] >

So the iframe's id ends up looking something like "photo_1278123687".

So, good thinking, Apple! Asinine, but there you go. Use "photo_frame" with impunity! (I assume, I didn't actually go back and try it... ;)

tedster

7:29 pm on Aug 12, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Welcome to the forums, JeanGenie.

Excellent debugging work, and thank you very much for documenting your findings for us.

juliemleonard

3:46 am on Sep 10, 2009 (gmt 0)

10+ Year Member



Thank you, thank you, thank you. I had been wrangling with this for a long time and was thinking I had just too many php if statements that Safari was interpreting differently or a missing div or something.

My computer came very close to death as well.

Thanks for posting the solution.