This article mainly shares with you how to solve the problem that html-jquery/js encounters the problem that it cannot be seen or 403 appears when referencing external images. The editor thinks it is quite good, so I will share it with you now and give it as a reference for everyone. Let’s follow the editor to take a look, I hope it can help everyone.
The solution is as follows:
<script type="text/javascript"> function showImg(url) { var frameid = 'frameimg' + Math.random(); window.img = '<img id="img" style="width: 100%;height: auto" src=\'' + url + '?' + Math.random() + '\' /><script>window.onload = function() { parent.document.getElementById(\'' + frameid + '\').height = document.getElementById(\'img\').height+\'px\'; }<' + '/script>'; document.write('<iframe id="' + frameid + '" src="javascript:parent.img;" frameBorder="0" scrolling="no" width="100%"></iframe>'); } </script> <p> <script type="text/javascript">showImg("图片url");</script> </p>
I have passed the test!
Related recommendations:
The path problem of referencing images in jsp pages_html/css_WEB-ITnose
The above is the detailed content of How to solve the 403 problem when html and jquery/js reference external images. For more information, please follow other related articles on the PHP Chinese website!