Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6730431
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T10:24:28+00:00 2026-05-26T10:24:28+00:00

I am developing a Rails application. One feature is providing customers the ability to

  • 0

I am developing a Rails application. One feature is providing customers the ability to preview HTML pages. I am loading these previews in an IFRAME, so that the CSS/styling of the preview container is separated from the CSS/styling of the preview itself. So far this works pretty well.

One problem I am having is auto-resizing the IFRAME once it has been loaded. I have this working great in Chrome just by attaching a function to the load event of the IFRAME via jQuery:

var show_preview = function() {
  $("#preview-loading").hide();
  $(this).show();
  this.style.height = this.contentWindow.document.body.scrollHeight + "px";
  return this.style.width = this.contentWindow.document.body.scrollWidth + "px";
}

$(function() {     
  return $("#preview_frame").load(function() {
    show_preview();
  });
});

This does not work very well in IE, however – the event appears not to be fired when the page first loads.

One work-around I am trying is to assign a function directly to the onload attribute of the IFRAME like so:

 <iframe onload="show_preview();" ...></iframe>

The problem I am having here is that the IFRAME cannot find the show_preview() function if it is defined in my JavaScript file. If I extract the function and put it in a SCRIPT tag above the IFRAME, everything works fine.

Appreciate any help – sure I am doing something bone-headed.

Max

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T10:24:28+00:00Added an answer on May 26, 2026 at 10:24 am

    Attach your function to the window object, then it will be visible in your html code:

    window.show_preview = function() { ... }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am developing an application with Rails 3, one of requeriments is unique meta
I am currently developing a Rails application using a database that was designed before
I am developing a Rails application that will access a lot of RSS feeds
I am developing a Rails application and would like to understand when to use
I'm developing a new rails application which is supposed to be installed several times
I've been developing my first rails application on my windows computer. But now i
I am developing a Rails 1.0 application (I can't upgrade, it's a strange situation)
I'm developing a Ruby on Rails application that needs to allow the user to
We are developing a considerably big application using Ruby on Rails framework (CRM system)
I am considering developing an application using Ruby on Rails that is a planner

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.