x This domain is for sale. If you intrested, Please contact : webspeckle@gmail.com

How can i access blogger variable in JavaScript?

Sometime we need to access blogger variable through javascript. You can easily get the the value in JavaScript by two methods

1) Direct access from JavaScript.
<script>
var blogURL = '<data:blog.url/>';
</script>
2) Set the value in an html element. Then access from JavaScript.
<div id="blogURL" data-blog-url="<data:blog.url/>"></div>
<script>
var blogURL = document.getElementById("blogURL").getAttribute("data-blog-url");
</script>
or

<input id="blogURL" type="hidden" value="<data:blog.url/>"/>
<script>
var blogURL = document.getElementById("blogURL").value;
</script>

No comments:

Post a Comment