1

How can I disable images and links from loading in HTML using a script.

<div id="mailPreviewTarget" style="padding: 10px; overflow: auto;">

    Sample Text
    <p></p>

    <img src="http://.../track/0/0.png">
    <div>

        <a href="http://.../unsubscribe/0/0">Unsubscribe</a>

    </div>

</div>

https://jsfiddle.net/ks8r3noa/2/

mac
  • 95
  • 8

3 Answers3

1
<script src="https://code.jquery.com/jquery-2.0.3.js">
$(window).load(function(e){
  e.preventDefault()
$('img , a').remove();  
});
</script>
mac
  • 95
  • 8
0
$(window).load(function(e){
$('img').css({'display':'none'});
$('a').css({'display':'none'});
});
-1

You can use this type of code to disable the images and links.

    <script>
    function buttonClicked()
    {
       document.getElementById('buttonId').disabled = true;
    }
    </script>
prime
  • 769
  • 1
  • 13
  • 27
  • Much appreciated. I tried it on Jsfiddle but to no avail. Can you check it yourself as well. Thanks. – mac Oct 10 '16 at 11:32
  • To disable link you can follow, http://stackoverflow.com/a/11901020/1246467. It works fine with Jsfiddle. You can use disableLink() function to achieve your task. – prime Oct 10 '16 at 11:48
  • If you want to disable the image, you have to put it inside a tag. ``. Then you can use the answer. It works fine in Jsfiddle. – prime Oct 10 '16 at 11:58