Search code examples
javascriptblogsblogspot

how to use blog variable on javascript


I'm using blogger.com. I need to use data:blog.url variable on the javascript. But i don't know how to assign to any javascript variable.

How to get blogspot variables on the javascript?


Solution

  • if this doesn't works:

    <script>
      var blogURL = '<data:blog.url/>';
    </script>
    

    then try this:

    <div id="blogurl" style="display:none;"><data:blog.url/></div>
    <script>
      var blogURL = document.getElementById('blogurl').innerHTML;
    </script>
    

    But if you want to get the page URL in javascript you can use window.location

    disclaimer: i've never used blogger