| Issue 4: | Auto-resize window based on iframe content size |
1 of 231
Next ›
|
| 5 people starred this issue and may be notified of changes. | Back to list |
There is code available on the web to get the size of the content in an iframe (as long as it is being served from the same domain for security reasons). It would be useful to be able to dynamically resize the nyroModal window to the size of the iframe's content. Height moreso than width.
Apr 16, 2008
I have some pages that I want to use in the modal windows that rely on form submission (to themselves) to work correctly. At the moment I do not want to convert everything to ajax. Can you give me a little more detail on how to change the size of the modal window if I can get the size of the iframe?
Apr 16, 2008
I have to write a new function to resize the nyroModal. With that, a new animation callback will coming out. I will try to do it asap but it's not an easy one to fit with the dimensions restrictions. I'll post a comment here once this new function is available in a new release.
Apr 19, 2008
In the version 1.2.0 there is a new function to resize the modal: $.nyroModalResize();
I tried some code to get the iframe content size and it looks like it works great
only in Firefox and only for same hostname pages.
Here is the code I used to test:
$.fn.nyroModal.settings.endFillContent = function(elts, settings) {
if (settings.type == 'iframe') {
var iframe = $('iframe', elts.content);
if (iframe.attr('src').indexOf(window.location.hostname) > -1) {
iframe.load(function() {
var body = iframe.contents().find('body');
$.nyroModalResize(body.width(), body.height());
});
}
}
};
I tested in Safari and IE, and it doesn't work. The body.width() and body.height()
doesn't work properly in Safari, the load event is not well fired in IE.
If you find a solution, be free to post it here !
As the page you open in iframe are in the same server, I suppose you can edit them.
If so, the best solution will be for you to add this code in your page opened:
$(function() {
var win = $(window);
parent.$.nyroModalResize(win.width(), win.height());
});
Or something like that, I didn't test it.
Status:
Fixed
|
if the page is in the same server, why don't use an ajax request? If so, you can resize the content from the ajax Call (as shown in the exemple) Let me know what do you want do if I can help. You can't do that in the iframe because of some issues in IE and Safari. The iframe is directly loaded, without waiting its loading. To get the iframe content size, maybe you can try something like: $('iframe').contents().height() and $('iframe').contents().width() (not tested)