/    Sign up×
Community /Pin to ProfileBookmark

[Almost there!] Cross domain autoresizing of iframes

Hi all,

Am not sure if this is the right section of the forum where to post this..but let’s try.

I guess most of us know about the problems with the automatic resizing of an iframe depending on the length of its content, when the main page

and the “iframe” page come from different domains (typical cross domain exception).
So I’ll skip an introduction…

I have the main page, MainPage.asp, which comes from [url]www.sisulabs.com[/url]. This page contains an iframe, itself containing a page, ExternalPage.asp,

which comes from another domain, [url]www.stealthmeasures.com[/url].

While trying to find a workaround, because I can (luckily in this case) access the source code of both websites, I have written some javascript

code that also in this cross domain case, can successfully (note to follow..) resize the iframe when its content changes, and what I like is

that all what I need to add to the “ExternalPage” loaded into the iframe, is one single line of code (the inclusion of a .js file coming from

[url]www.sisulabs.com[/url] and does everything).

This javascript tries to resize directly the iframe on the onload event. If this throws a cross domain exception (being in ExternalPage.asp,

this javascript can only access [url]www.stealthmeasures.com)[/url], then it dynamically adds a hidden iframe to the page, and loads into this hidden

iframe a page coming from the other domain ([url]www.sisulabs.com[/url]) that can then resize the iframe overcoming the cross domain limitation.

Problem is: it works great in Internet Explorer (both 6 and 7), but in Firefox it looks like it is trying to load something (the status bar

displays “transferring data from www.sisulabs.com” which is the main domain) and does not resize the iframe.

The url where you can (hopefully) have a look is [url]http://www.sisulabs.com/MainPage.asp[/url]

Any ideas?

Many thanks in advance.

to post a comment
JavaScript

1 Comments(s)

Copy linkTweet thisAlerts:
@SisupoikaauthorJan 18.2008 — uhm... have noticed something strange... it works with FF too somewhere else.

Can you please tell me if it works for you with both FF and IE?
×

Success!

Help @Sisupoika spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.18,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...