当前位置:Gxlcms > JavaScript > html和jquery/js引用外部图片时出现403的问题如何解决

html和jquery/js引用外部图片时出现403的问题如何解决

时间:2021-07-01 10:21:17 帮助过:6人阅读

本文主要和大家分享解决html-jquery/js引用外部图片时遇到看不了或出现403的问题。小编觉得挺不错的,现在就分享给大家,也给大家做个参考。一起跟随小编过来看看吧,希望能帮助到大家。

解决方法如下所示:

<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>

本人已经测试通过了!

相关推荐:

在jsp页面中引用图片的路径问题_html/css_WEB-ITnose

以上就是html和jquery/js引用外部图片时出现403的问题如何解决的详细内容,更多请关注Gxl网其它相关文章!

人气教程排行