thickbox, https, ie6 and os x firefox compatibility issues
This might be the most obscure problem ever, but it caused me such a headache that I thought I would blog about it on the off chance that one person might have this same issue.
First off I’m using ThickBox to handle some of the cool visual effects in the JumpBox admin interface. Such as:
Everything was fine and dandy until we decided to start serving the admin interface over https. This worked for all browsers EXCEPT IE6. In IE6 when ThickBox tries to display you get this security warning:
“This page contains both secure and nonsecure items. Do you want to display the nonsecure items?”
After a small amount of searching on the ThickBox forums I found a post that referenced a blog post about iframes, https, and IE. The conclusion is that ThickBox creates an iframe without a “src” attribute, and in IE6 over HTTPS this throws up the warning as seen above. So the solution is to add a src attribute to the iframe and point it at a blank html file on the server.
The fix is achieved by modifying the ThickBox javascript file. Near the beginning of the TB_show function the following line:
$(“body”).append(“<iframe id=’TB_HideSelect’></iframe><div id=’TB_overlay’></div><div id=’TB_window’></div>”);
… should be changed to:
$(“body”).append(“<iframe src=”blank.html” id=’TB_HideSelect’></iframe><div id=’TB_overlay’></div><div id=’TB_window’></div>”);
As advertised this fixes the warning from IE6. However this breaks… something… in Firefox 2 on OS X. I say “something” because I really don’t know what is going on. Everything works fine in Firefox on XP, Safari, IE6 and IE7. Here’s a screen grab:
Apparently this weirdness is caused by the src=’blank.html’ on the iframe. How this is causing problems is beyond me. The solution is to do a little browser detection to determine if we’re dealing with IE, in that case add the src attribute to the iframe, and the rest of the time forget about it:
if(navigator.appName == “Microsoft Internet Explorer”) {
$(“body”).append(“<iframe src=’blank.html’ id=’TB_HideSelect’></iframe><div id=’TB_overlay’></div><div id=’TB_window’></div>”);
} else {
$(“body”).append(“<iframe id=’TB_HideSelect’></iframe><div id=’TB_overlay’></div><div id=’TB_window’></div>”);
}
To anyone still reading, I hoped this helps. Otherwise sorry you had to listen to me rant about another JavaScript issue that is fueling my hatred of supporting multiple browsers.
UPDATE: Mark was kind enough to point out that instead of using a blank html file as the source of the iframe, you can use “javascript:false;” which is compatible with all browsers thus eliminating the need to do browser detection. So instead of that ugly chunk of code seen above, all you need is:
$(“body”).append(“<iframe src=’javascript:false;’ id=’TB_HideSelect’></iframe><div id=’TB_overlay’></div><div id=’TB_window’></div>”);
This is a much simpler and cleaner solution.





May 16th, 2007 at 4:04 am
I cannot find sufficient words to thank you for this post.
I was about to give up using thickbox under https, and with you came down the “light”.
Thanks again pal,
Nicolas
May 16th, 2007 at 9:29 am
Glad I could help!
May 21st, 2007 at 5:31 am
Thanks for this. I just had the exact same problem. I used “javascript:false;” rather than blank.html to avoid any potential 404s in Firefox. I am hoping this removes the need for the browser sniffing.
May 22nd, 2007 at 10:56 am
I’ll have to give “javascript:false” a try. If that works cross browser, it would make for a much cleaner solution. Thanks for the tip!
October 9th, 2007 at 5:01 pm
The javascript:false worked great, thanks!
January 11th, 2008 at 11:59 am
A thousand Thank yous! You saved my butt
April 16th, 2008 at 5:14 pm
i love you… thanks for this
June 6th, 2008 at 12:00 am
I am opening an https page from http page in thickbox. However I can only see the loading image and the page doesn’t open at all. This works fine if only http is used.
Any solution for this.
Thanks in advance.
June 6th, 2008 at 3:00 pm
To make this change for the “minimized” version. Find the list of pipe-delimited labels and look for |iframe|. Change this to
|iframe src=\’javascript:false;\’|
Note: you have to escape the single quotes.
June 26th, 2008 at 2:46 am
Hey Man, just wanted to say thanks for this post. I was experiencing the same exact problem and you solved it. Thank you so much! Gotta love using HTTPS on IE6!
July 7th, 2008 at 10:25 am
Hey Ben, Just a quick note to say thank you for this post. You answered all my questions and saved hours of investigaton through one simple solution. I’ll buy you a pint next time your around here (Glasgow,Scotland)
DC
July 11th, 2008 at 3:16 pm
Thanks for the post. We were having this issue and this fixed it.
August 3rd, 2008 at 11:52 pm
Thank you thank you thank you have a deadline of 3 hours to fix this – thank YOU!!!
August 21st, 2008 at 8:24 am
ThankssssssssoMUCH!
Nice post man!
August 28th, 2008 at 9:19 am
Excellent! Was trying to find the missing src — silly iFrame!
October 7th, 2008 at 8:34 am
Brilliant. Thanks for publishing.
October 7th, 2008 at 8:44 am
Yeah, I used this on my site at http://www.lifelister.com/. Was having major issues https and this was the solution.
Thanks!
January 22nd, 2009 at 10:31 pm
[...] Mostly for personal reference but hey, it’s a personal blog, and this just cost me three hours. cause IFRAMEs without a SRC might throw up an error in IE6 on HTTPS, but they don’t actually make a request so staring at a HTTP sniffer proxy doesn’t do you much good. ← previous post next post → Archives [...]
January 29th, 2009 at 9:51 am
Thanks a lot, I had been using blank images in the past to solve this problem for a tooltip (they work in safari) didn’t realize javascript:false; would also work.
March 22nd, 2009 at 12:57 pm
Yes. Yes yes yes!
March 28th, 2009 at 3:25 am
Thanks!
May 20th, 2009 at 4:57 am
That’s amazing!
Thank you so much!
I have been searching for the solution couple of days! Your advice works! I am happy now!
September 16th, 2009 at 6:38 am
Thank’s very much, It would have taken me hours to track down such an obscure bug.
October 12th, 2009 at 10:01 pm
Brilliant, thanks heaps!
December 15th, 2009 at 9:58 am
Yet another grateful post. Like Demoli said, it’d take hours of testing to find this one bug in this particular situation.
February 25th, 2010 at 12:27 am
Hi,
Anyone solve thickbox overlay issue with ie6, im facing the only half the page is getting overlayed if scroll in the page……
i tried changing the tb_poistion function as well but no luck…
any idea.. plz
April 14th, 2010 at 8:08 pm
Thanks! Saved me a whole lot of headache…