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.
1) Direct access from JavaScript.
<script>2) Set the value in an html element. Then access from JavaScript.
var blogURL = '<data:blog.url/>';
</script>
<div id="blogURL" data-blog-url="<data:blog.url/>"></div>or
<script>
var blogURL = document.getElementById("blogURL").getAttribute("data-blog-url");
</script>
<input id="blogURL" type="hidden" value="<data:blog.url/>"/>
<script>
var blogURL = document.getElementById("blogURL").value;
</script>
No comments:
Post a Comment