title: HTML read javascript and put result into a div
body: <p>I'm new to HTML/javascript and I want to make something that displays Last.FM current playing songs, into a div on html, which displays it in text, I have a code that sends the current song through a chat on www.irccloud.com, and I was wondering If you could change it so that It could get received and put into a DIV on a page, the code is below:</p>
  
  <p>and var r is the completed code, so how would I do something in the div that picks up the source as the link above and then grabs var r from it? If so, how would I do it??</p>
  
  <p>I have tried the following code <a href="http://jsfiddle.net/7VCck/" rel="nofollow">here</a></p>
  
  <p>Sorry if I do not make sense.</p>
  
  <pre><code>(function () {
              var e = "DeviousRunner";
              window.lfmRecentTrack = function (t) {
                  var n = (new Array).concat(t.recenttracks.track)[0];
                      var album, spurl;
                      if (n.album["#text"]) {
                          album = " (from " + n.album["#text"] + ")";
                      } else {
                          album = "";
                      }
                      try {
                          var spotify = new XMLHttpRequest();
                          spotify.open("GET", "https://ws.spotify.com/search/1/track.json?q=" + encodeURIComponent(n.artist["#text"] + " - " + n.name), false);
                          spotify.send();
                          var spotresp = JSON.parse(spotify.responseText);
                          if (spotresp["tracks"].length &gt; 0) {
                              //var urisplit = spotresp["tracks"][0]["href"].split(":");
                              //spurl = " https://open.spotify.com/" + urisplit[1] + "/" + urisplit[2];
                              spurl = spotresp["tracks"][0]["href"];
                          } else {
                              console.log("spotify: couldn't get url");
                              spurl = "";
                          }
                      } catch(e) {
                          console.log("spotify: " + e.message);
                          spurl = "";
                      }
                      var r = "is listening to " + n.name + " by " + n.artist["#text"] + " " + album + " (" + spurl + ")";
              }
              var n = document.createElement("script");
              n.setAttribute("type", "text/javascript");
              n.setAttribute("src", "https://ws.audioscrobbler.com/2.0/?method=user.getrecenttracks&amp;user=" + e + "&amp;api_key=dd5fb083b94a7196cf696b9d7d11bc63&amp;limit=1&amp;format=json&amp;callback=window.lfmRecentTrack");
              document.body.appendChild(n)
          })();
  </code></pre>