• 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.

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

Scheduled Pinned Locked Moved Development
5 Posts 3 Posters 1.2k Views 3 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.
  • S Offline
    s1h4d0w
    last edited by s1h4d0w Jun 2, 2019, 10:51 PM Jun 2, 2019, 10:46 PM

    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 Offline
      s1h4d0w
      last edited by s1h4d0w Jun 2, 2019, 11:29 PM Jun 2, 2019, 10:54 PM

      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

      ? S 2 Replies Last reply Jun 3, 2019, 12:21 AM Reply Quote 0
      • ? Offline
        A Former User @s1h4d0w
        last edited by Jun 3, 2019, 12:21 AM

        @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 Offline
          sdetweil
          last edited by Jun 3, 2019, 1:36 AM

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

          Sam

          How to add modules

          learning how to use browser developers window for css changes

          1 Reply Last reply Reply Quote 0
          • S Offline
            s1h4d0w @s1h4d0w
            last edited by s1h4d0w Jun 3, 2019, 11:46 AM Jun 3, 2019, 10:42 AM

            @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
            1 / 1
            • First post
              1/5
              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