• Recent
  • Tags
  • Unsolved
  • Solved
  • MagicMirror² Repository
  • Documentation
  • 3rd-Party-Modules
  • Donate
  • Discord
  • Register
  • Login
MagicMirror Forum
  • Recent
  • Tags
  • Unsolved
  • Solved
  • MagicMirror² Repository
  • Documentation
  • 3rd-Party-Modules
  • Donate
  • Discord
  • Register
  • Login
A New Chapter for MagicMirror: The Community Takes the Lead
Read the statement by Michael Teeuw here.

Html into Iframe

Scheduled Pinned Locked Moved Troubleshooting
2 Posts 1 Posters 1.8k Views 1 Watching
Loading More Posts
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • R Offline
    romain
    last edited by romain Jun 13, 2017, 9:55 AM Jun 13, 2017, 9:19 AM

    Hello, I try to put my own html code into an iframe but it doesn’t work. How shoudl I that ?
    I tryed :

    getDom: function() {
      var wrapper = document.createElement("div");
      var iframe = document.createElement("iframe")
    
      iframe.src = this.file("biblop.html")
    
      wrapper.appendChild(iframe)
      return wrapper
    }
    

    No error, (I can see the border of the iframe) yet nothing happen in it

    I tryed to “write” the html into the iframe as well, thinking that I could use the node helper to read my html file to get the content eventually.

    getDom: function() {
      var wrapper = document.createElement("div");
      var iframe = document.createElement("iframe")
    
      var myContent = ''
         + 'My dynamic document' 
         + '<p>Hello world</p>';
    
      iframe.contentWindow.document.open('text/htmlreplace'); 
      iframe.contentWindow.document.write(myContent);
      iframe.contentWindow.document.close();
     
      wrapper.appendChild(iframe)
      return wrapper
    }
    

    But content.Window is null every time so it can’t be open.
    I tryed to tweak those two solution in different ways (like using absolute path) but the end result was the same.
    How can I do that ?

    (PS: I tryed the first code I wrote above outside of the magic mirror first on my ubuntu and it was working just fine. Soemhow it’s the magic mirror itself that don’t like it)

    1 Reply Last reply Reply Quote 0
    • R Offline
      romain
      last edited by Jun 13, 2017, 10:14 AM

      Scratch that, the first example is working. It’s just that, because of the body black background, the text inside the iframe wasn’t visible. Justed needed to to change the css for the iframe to overide the background of the body

      1 Reply Last reply Reply Quote 0
      • 1 / 1
      1 / 1
      • First post
        1/2
        Last post
      Enjoying MagicMirror? Please consider a donation!
      MagicMirror created by Michael Teeuw.
      Forum managed by Sam, technical setup by Karsten.
      This forum is using NodeBB as its core | Contributors
      Contact | Privacy Policy