Menu

#588 iframe has two attributes of the height parameter

workingwiki
open
None
5
2014-08-22
2014-08-18
Anonymous
No

And that can be confusing, for example, I get an iframe for my d3.js with the height 8px (see the attachment). It works fine in Firefox, but in Chrome sometimes not.

The link is http://yushan.mcmaster.ca/theobio/akhmetzhanov/index.php/HIV_prevalence_in_Africa (but the page might be changed soon)

1 Attachments

Discussion

  • Andrei Akhmetzhanov

    (Andrei)

     
  • Lee Worden

    Lee Worden - 2014-08-18

    That's odd, the code is written to create the iframe at height 1000 (here, at line 2216) and then resize it to fit the content once it loads (here, line 22).

    I'm not sure where that style= is coming from. I'll try to track it down. What problems does it cause? Does it fail to resize properly after loading the map?

     
  • Lee Worden

    Lee Worden - 2014-08-18

    This looks relevant: http://stackoverflow.com/questions/3085530/chrome-iframe-display-white-box

    It might be that the empty <body> tag that fills the iframe before its content loads comes with margin: 8px. Seems like that wouldn't cause a literal style attribute to appear though.

     
  • Lee Worden

    Lee Worden - 2014-08-18

    I notice the iframe code is sort of old and it'd be nice to reorganize it using the jQuery and ResourceLoader features that are available in post-1.19 MediaWiki. Maybe I'll just do that and see if the problem goes away :)

     
  • Andrei Akhmetzhanov

    Lee, the problem is that if I create the button "Play" before creating the canvas svg, then the height in the iframe will be inherited from the button (which I assume, exactly 8px).

    In Chrome I can use Inspector and switch between your height 1000 and style:height=8px, but the browser chooses the latter by default

     
  • Andrei Akhmetzhanov

    ps: however, I am confused by 524px in my previous example :/

     
    • Lee Worden

      Lee Worden - 2014-08-18

      OK! My javascript code is assuming that once the HTML is loaded into
      the iframe, its height won't change any more. So you may be seeing
      different heights at different times because it's random whether it does
      the height adjustment before or after your code creates the canvas.

      There must be a way to fix this - it's not obvious, because your code is
      prohibited from touching things in the outer document, so you can't have
      it update the iframe's size. I guess my code can watch the iframe
      contents and keep the height updated. I wouldn't want to spend wasteful
      computation checking on iframes excessively - maybe there's a better way.

      Or would it work for you to write your html so that its body is
      initialized with the full height, and stays the same size?

       
  • Lee Worden

    Lee Worden - 2014-08-18

    Well, this link makes it look easy to track size changes in the iframe's content. So I should try that - if it works as advertised you won't need to change anything.

     
  • Andrei Akhmetzhanov

    Lee, thanks - I would like to keep the possibility to update the height. Ex: if I want to have it connected with the window size of my browser

     
    • Lee Worden

      Lee Worden - 2014-08-18

      On 08/18/2014 02:31 PM, Andrei Akhmetzhanov wrote:

      Lee, thanks - I would like to keep the possibility to update the height.
      Ex: if I want to have it connected with the window size of my browser

      OK, I think I can do that.

      I don't think you can get window size changes from within an iframe
      though. The iframe is designed to wall off the page within from the
      stuff outside, for security.

      However, you could do it by writing some separate javascript that runs
      in the outer page. I'd be happy to talk to you about that. Once you do
      that, you can resize the iframe yourself if you want.

       
  • Lee Worden

    Lee Worden - 2014-08-19

    reorganize it using the jQuery and ResourceLoader features that are available in post-1.19 MediaWiki. Maybe I'll just do that and see if the problem goes away :)

    Reorganized and made the problem go away. It should now automatically resize the iframe if the document within resizes. Let me know if you have any further trouble with it.

     
  • Lee Worden

    Lee Worden - 2014-08-19
    • status: open --> closed
    • assigned_to: Lee Worden
     
  • Andrei Akhmetzhanov

    Super! Thanks a lot! (I will write if I notice smth)

     
  • Andrei Akhmetzhanov

    Lee, sometimes when I load the page, I get the height of an iframe 100px. It can be changed to normal by Ctrl-F5

    Do you have an idea why?

    Thank you in advance

     
    • Lee Worden

      Lee Worden - 2014-08-21

      Maybe you're getting a cached page, with the old javascript and css.
      Let me know if the problem persists longer-term, or happens after you
      edit the page, please.

       
    • Lee Worden

      Lee Worden - 2014-08-21

      OK, I'll do you one better - I just loaded the page and got no iframe!

       
  • Lee Worden

    Lee Worden - 2014-08-21
    • status: closed --> open
     
  • Andrei Akhmetzhanov

    Yes, I have checked that. It happens only when I load the page at the first time. Then I use Ctrl-F5 and it gets Ok.

    Lee, if you are logged-in to that page, do you see it normally?

     
  • Andrei Akhmetzhanov

    ps: I meant it is not connected with a long cache thing.

     
  • Andrei Akhmetzhanov

    ps2: and I saw it only in Firefox (it works normally in Chrome)

    the problem does not disturb me a lot - maybe, we can keep it for later

     
  • Andrei Akhmetzhanov

    If the page is loaded slowly, then the height can be even 0px, see the attachment: in Chrome it might go further and update the page to its supposed height after, but in FF it does not happen by some reason and I need to refresh the page by myself

     

Anonymous
Anonymous

Add attachments
Cancel





Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.