Monday, October 27. 2008Autofitting iFrameTrackbacks
Trackback specific URI for this entry
No Trackbacks
Comments
Display comments as
(Linear | Threaded)
Glad to see you posted this.
I was at the code camp session sitting in the front row! I'll see if I can come up with alternate solutions.
Using fragment ID communication is likely to be problematic once IE 8 comes out. I believe the IE team has publicly said they placed new restrictions on fragment ID communication in IE 8, and implementations should switch to HTML5's postMessage approach. Using postMessage should also work in the latest Firefox and Opera browsers, and Safari should have it soon too.
So detect for postMessage and use that when possible, then fall back to fragment IDs.
Aren't URL query-strings a critical feature of billions of websites?
I was under the impression the technique above uses fragment IDs (the #part of an URL) to communicate across domains, and that setting the location of a parent or child with a new #value is how the technique works. So in that case, querystring parts (the ?name=value parts) are not involved?
If that is the case, Microsoft has placed new limitations on setting the parent (and child?) locations with different #values that may not work as expected in IE 8. I am not aware of the details, but postMessage was mentioned as the way to work around those issues. I think the issue is the permissions on parent/child frames changing urls with fragment IDs in other frames. I could be misunderstanding the technique though.
the misunderstanding may be mine, as i'm new to this.
but i believe the technique uses query-strings (which get passed to the server, and are preceded by a question-mark), and not fragment id's (which do not get passed to the server, and are preceded by the # pound-sign "hash-mark"). http://andrew-ford.com/stw/node63.html here's the script-line which loads the hidden iframe: iframe.src = path + '?height=' + height; so maybe i was incorrect to reference the tagneto article. is support of query strings going to change?
Oh, OK. It sounds like then the parent frame is telling the child iframe the size. I thought it was a technique for the child to tell the parent page how big the child needs to be.
So that should still work, sorry for the confusion.
Sorry for the double-post. I re-read the comment again, and if the child iframe uses a hidden frame to load a page on the parent's domain with the querystring, and that hidden page tells the parent page via javascript the child size, that may work, but it would be good to test in IE 8 beta 2 to confirm.
There were some errors in my code. All code fragments and downloads have been corrected.
Tested fine on IE 8 beta 2. See Notes above re browser differences.
Hello JohnW,
There is a tiny tiny problem. The download link http://uploadingit.com/files/914996_sbtif/resize.zip doesn't work any more (file not found). Thanks
First off, thanks a ton! I have been trying to find a solution for days.
I did want to raise one issue (which I resolve below). Cross domain security issues will still arise if a user access your site with http://somedomain.com/parentPage.htm, and your child page uses loadHiddenIframe("http://www.somedomain.com/hiddeniframe.html");, or vice-versa. To resolve this, here is what I came up with (in 3 steps): 1- CHANGE resize.js to the following: function QueryString(key) { var value = null; for (var i=0;i
So, will this method to resize external iframes still work on the latest ie 8 and firefox?
Im no professional scritper though I think this script could be my answer to my prayers, though wasnt sure if it was still compatible? many thanks J:)
this pulls up an error on page in ie 8, if the remote iframe is called without name="surveyFrame" id="surveyFrame" being added to the local iframe field.
so not good if you need to call the remote iframe and dont want to have it auto resized. I need some iframes resized, i need some left alone so get the below error on page if I dont add the top attributes to every local iframe field. Message: 'null' is null or not an object Line: 26 Char: 2 Code: 0 URI: http://www.mydomain.com/resize.js regards Jason
The link to the above .js file is broken. Are you able to restore it?
http://boxstr.com/files/4208942_69kfi/resize.zip Thanks. Geoff
I tried this technique but I still get sccess denied errors. Anyone know why?
|
RegisterSoCal Code Camp SessionOur SponsorsCollaborateBlog Administration |