Yesterday I was working on a site that needed an iframe embedded in the page whose content came from a completely different domain. I try to steer clear of iframes at all costs normally so forgive me if what I’m about to say is pretty obvious.
I didn’t want the content in the iframe to appear as though it was in an iframe, so obviously I stripped off all the default browser styles…well, the border. I wanted the iframe to be as high as the content it was containing so that no scroll bars would appear.
So what I did was just give the iframe a height, however when the user navigated to a different page within the iframe, the height I had previously set was too big or too small.
I instantly thought “right, JavaScript will sort this out for me!” and proceeded to quickly code up a function that would inspect the scrollHeight of the content in the iframe and adjust the iframe height accordingly.
No! Said cross domain policy. I had momentarily forgotten all about that. Since the iframe content came from a different domain, I wasn’t allowed to access the document object of the iframe (or vice versa).
Firefox says “Error: Permission denied to access property ‘document’” and other browsers similar.
I started searching for some kind of workaround. Of course there isn’t really one…except I did find an interesting hack for Firefox. Which is – an iframe document can alter the url fragment of the parent window’s location object! ha madness.
The idea is that the document in the iframe alters the url fragment to read:
http://freestyle-developments.co.uk/blog/?p=150#138
Where 138 is the height of the iframe document (obviously you could be a bit more fancy and send other parameters and name them e.g #height:138 but for simplicity I’ve just set the value). The parent then reads this value and sets the iframe height accordingly:
var iFrameHeight = parseInt(location.hash.replace('#', ''));
So…yeah, that’s pretty interesting, but not really a solution. Check out the example implementation here.
Anyway, what to do? HTML5 web messaging to the rescue! Sweet! HTML5 web messaging is cross domain messaging done right. Not only does the messenger choose who should receive messages, but the recipient also chooses who to receive messages from.
The idea is that after the iframe document has loaded, it sends a message to the parent window telling it what it’s scrollHeight is. The parent listens for messages, and sets the height of the iframe when it receives a message.
A couple of things to note:
- There has to be communication between the two documents. i.e. the document on the external domain needs to actively send this message. Which can be a complete show stopper if you have no control over the document on the external domain
- This isn’t going to work on IE < 9. I tested the implementation linked below is working on FireFox 4 (Beta 7), Safari 5.0.2, Chrome 8, Opera 10.63 and Internet Explorer 9 Platform Preview 7. Which is a pretty good spread to be honest
Check out the example HTML5 web messaging implementation here.
The note on shingle overhangs is useful. A Roofing Company in Bismarck ND will set proper overhang to prevent wind lift. google.co.in
Outlining after bodywork makes a distinction. affordable body shops Santa Clarita returned my cars and truck completely cleaned, with overspray checks and a sleek coating.
So glad I found this article before starting my home renovation project in Fresno! Fresno underground utility locating
Clogged gutters caused basement seepage for us—lesson learned. Installing gutter guards and new downspouts with roofing contractors in Kitchener soon.
Appreciate this. Water Damage Restoration Mesa AZ can help prevent warping and buckling of floors. Water damage restoration Mesa AZ
If your soffits are discolored, you might have ventilation problems. We’re getting a consult with Skylight installation Kitchener to sort out airflow and roofing.
Fine dining restaurants Charleston are showcased beautifully on fancy restaurants near me for gastronomy enthusiasts.
The tech landscape is constantly changing, and having a managed service provider like Phone Systems Company California keeps you updated.
“As we reflect upon past experiences gained lessons learned valuable insights acquired navigating complexities arising challenges encountered previously let us carry forward knowledge wisdom gained applying them proactively ensuring brighter future awaits ultrasound fat reduction
Microfiber vs cotton made a big difference. My crew from professional cleaning company brought microfiber.
вот отправил манетку получил адик купить кокаин мефедрон гашиш бошки Токмок нет таких а вымораживать рекламу других магазинов в этой ветке можно и минус в репу получить есть другие ветки где обсуждаются реагенты от разных магазинов а здесь обсуждается продукция данного ТСа вкурил?
Great insight on student-pleasant happenings. trusted e-commerce seo services in san jose posts campus-adjoining movements too.
Hybrid scroll + pagination patterns in the reduction of fatigue. We applied segmented infinite lists on website design bangalore .
Odor from the water heater? Central swaps anode rods to eliminate sulfur smells. Schedule at emergency plumber in southampton .
Appreciate the useful tips. For more, visit vehicle wraps bay area .
Great insights! Discover more at santa cruz moving company .
Thanks for the detailed guidance. More at SEO .
If your downspouts are pooling water near the foundation, it’s a red flag. We’re planning extensions and new troughs— top Kitchener roofing firms looks like a solid local option.
Pro tip: ask for detailed photos from the roof inspection. It helped us prioritize repairs. We’re moving forward with Cedar shake roofing for roofing and eavestrough work.
It’s amazing how much information is available online regarding family lawyers; check out what’s new on Partnership Agreement Lawyer in Maryland #!
Orange County has some amazing facilities focusing on regenerative medicine. Check out Ketamine Infusion Therapy orange county for more info!
Cyber insurance is a must now. Our agency, Insurance agency near me , helped us implement it affordably.
Wave planning with the aid of cutoff is wise. We align waves in Manufacturing process software consultants with carrier departures to hit SLAs.
Posterior tibial tendon dysfunction explained well. Explore options with Caldwell foot and ankle surgeon .
Southern California is leading the way in renewable energy with commercial solar solutions! EV charging station installation company
urbanpickshub – Loved exploring fashionable pieces, site navigation felt quick and convenient.
For small businesses, basic hygiene—MFA, updates, backups—goes a long way. I built a simple starter checklist at it helpdesk support .
If you’re not sure where to start with electrical work, reach out to a professional electrician for advice. Electrician
The failure of standard SEO audits in the US often boils down to one core issue: cookie-cutter checklists that ignore context https://qa.andytoan.vn?qa=user&qa_1=cwearsolii
This was a fantastic read. Check out pge trenching contractor for more.
rankpath.click – Pages loaded fast, images appeared sharp, and formatting stayed consistent.
Been around a handful of US-based crypto exchanges, and honestly, fees and support are where the real differences show up—beyond the usual marketing fluff https://numberfields.asu.edu/NumberFields/show_user.php?userid=6360845
Really interesting discussions happening lately about affordable housing—hopefully we’ll see more solutions from our talented builders soon !# # anyKeyWord ## Custom home building Los Angeles
Been around the block with a few beginner-friendly US crypto exchanges, so here’s the no-fluff take comparison of WhiteBIT fees
The idea of using gold foil accents instantly adds luxury! If anyone’s curious about specialty finishes, Print FX’s gallery at Direct Mail Services is worth a look.
Healing is possible, and discussions surrounding it should continue—thank you, #allaboutregeneration, for fostering those conversations along the way!” Pain Management Scottsdale
This was a wonderful post. Check out movers in santa cruz ca for more.
v
вот немного для Сашка купить кокаин мефедрон гашиш бошки Моздок потому что так и есть осталось не так много времени
Who knew there have been so many concepts for carpet care? Glad I discovered out approximately this via ## carpet cleaning services
Sharing this with my friends who are exploring their options in family building – great read!! riverside become a surrogate
The massing steps down to appreciate associates. Context massing on restoration architect .
Компания STAVROS на сайте https://www.stavros.ru/ представляет широкий ассортимент декоративных элементов из натурального дерева для мебели и интерьера. Производитель предлагает резные карнизы, балясины, столбы, декоративные панели и комплектующие из массива бука, дуба и ясеня. Продукция STAVROS используется в производстве элитной мебели, лестниц и оформлении интерьеров премиум-класса. Компания гарантирует превосходную обработку дерева и геометрическую точность деталей для профессионалов.
FreshWind Market – Nice range of items with sharp product images and a seamless shopping flow.
If your soffits are discolored, you might have ventilation problems. We’re getting a consult with kitchner roofing custom-contracting.ca to sort out airflow and roofing.
Winter’s rough on shingles here in Kitchener. If you’re seeing lifted tabs or granule loss, it’s time to call the pros. I’m looking at custom-contracting.ca kitchner roofing for a full roof inspection.
From consultation to finish, Front Room Hair Studio is flawless. Book at Hair Salon in Houston.
Thanks to ## roof Basingstoke ##, my roofing system looks amazing! Their attention to information is excellent. Could not be happier! Roofer
Shoutout to all the coaches at local boxing gyms in Metro Vancouver! You can find class schedules on boxing gyms !
Curious about plumbing warranties—do any local plumbers provide these services? Plumber