Resizing the iframe

Is there any way to adjust the iframe obtained from p5 alpha text editor so that its height and width equals the canvas inside?

Answers

  • Plz provide some code. Otherwise the onky answer I can suggest is css.

    Kf

  • edited May 2018

    I'm trying to dynamically render the iframe from alpha p5 text editor in react

    render() { return(<iframe src = {src obtained from p5 text editor}></iframe>) }

    I need to adjust the size according to the size of the canvas inside. Thank you

  • Answer ✓

    You need to be clearer about your requirements. Are you saying you want to resize the iframe to the size of the canvas being loaded into it? That might be relatively tricky and involve communication between iframe content and host page.

    If you just want to make contents of iframe adapt to iframe size then you essentially have the same requirements as someone wanting to make a responsive canvas.

  • I remembered there's a JS library that resizes iframes to their contents: https://github.com/davidjbradshaw/iframe-resizer

  • edited May 2018

    I'm sorry for not being clear. You are right, I want to resize the iframe according to the content inside, i.e the canvas.

Sign In or Register to comment.