Thursday, September 11, 2014

How to set default ALT text to all images?



Copy and paste the javascript code before the </head> tag and insert onload="init()" in the <body> tag.

<script type="text/javascript">
//<![CDATA[
    function init() {
        imgs = document.images;
        for (i = 0; i < imgs.length; i++) {
            imgs[i].alt = "";
        }
    }
//]]>
</script>

<body onload="init()">

It is also possible to put a dynamic ALT text. For example, in blogger templates, instead of 'Change ALT Text' you can put '<data:blog.pageTitle/>' based on the page title of the post.

No comments:

Powered by Blogger.
  • LALREMLIEN NEITHAM
  • +