Navigation

    MagicMirror Forum

    • Register
    • Login
    • Search
    • Recent
    • Tags
    • Unsolved
    • Solved
    • MagicMirror² Repository
    • Documentation
    • Donate
    • Discord

    First module I'm developing, HTML won't render

    Development
    3
    5
    709
    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.
    • S
      s1h4d0w last edited by s1h4d0w

      I installed Magic Mirror for the first time today and was looking for a way to show a webpage. I couldn’t really find anything and having installed a few modules and being a web developer I thought I’d give it a crack.

      I’ve used another simple module as reference and after double checking with the documentation it seems like everything should be correct. However the container for the module is created, but there’s no content. Maybe there’s some restriction that I’m not aware of?

      My file structure is:

      /Modules
          /MMM-WebView
              - MMM-Webview.js
              /css
                  - MMM-WebView.css
      

      MMM-WebView.js:

      Module.register("MMM-WebView", {
      
          defaults: {
              url: "https://www.duckduckgo.com"
      		},
      
          start: function() {
              var self = this;
          },
      
          getStyles: function() {
             return ["modules/MMM-WebView/css/MMM-WebView.css"];
          },
      
          getDom: function() {
      
            var wrapper = document.createElement("div");
            wrapper.classList.add("wv-wrapper");
            
            var iframe = document.createElement("iframe");
            iframe.setAttribute("src", url);
            iframe.innerHTML = " ";
            
            wrapper.appendChild(iframe);
            
            return wrapper;
            
          },
      
      });
      

      And in my config:

      {
      	disabled: false,
      	module: 'MMM-WebView',
      	position: "middle_center",
      	config: {
      		url: "https://open.spotify.com"
      	}
      },
      

      Is there something I’m missing?

      1 Reply Last reply Reply Quote 0
      • S
        s1h4d0w last edited by s1h4d0w

        In the document structure the filename is actually “MMM-WebView.js” with a capital V but when trying to edit my post the website is saying that Aksimet suddenly picked it up as spam so I can’t fix that.

        I’ve created a github with all files: https://github.com/s1h4d0w/MMM-WebView

        Sean S 2 Replies Last reply Reply Quote 0
        • Sean
          Sean Module Developer @s1h4d0w last edited by

          @s1h4d0w

          iframe.setAttribute("src", this.config.url);
          

          Anyway, your url "https://open.spotify.com" will not be opened.

          0_1559521166346_sa.png

          1 Reply Last reply Reply Quote 0
          • S
            sdetweil last edited by

            Also don’t need the path for the CSS file. It will be searched first in the module folder

            1 Reply Last reply Reply Quote 0
            • S
              s1h4d0w @s1h4d0w last edited by s1h4d0w

              @Sean said in First module I'm developing, HTML won't render:

              @s1h4d0w

              iframe.setAttribute("src", this.config.url);
              

              Anyway, your url "https://open.spotify.com" will not be opened.

              Ah thank you! At least now I know what I was doing wrong, will be tinkering some more. Seems like I need to include /embed/ in the spotify url to get it to be accessible.

              And thank you @sdetweil, also a handy tip!

              1 Reply Last reply Reply Quote 0
              • 1 / 1
              • First post
                Last post
              Enjoying MagicMirror? Please consider a donation!
              MagicMirror created by Michael Teeuw.
              Forum managed by Paul-Vincent Roll and Rodrigo Ramírez Norambuena.
              This forum is using NodeBB as its core | Contributors
              Contact | Privacy Policy