欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  web前端

html-jquery/js引用外部图片时看不了或出现403解决办法

程序员文章站 2024-01-29 17:37:52
...
html-jquery/js引用外部图片时看不了或出现403怎么回事?本文主要为大家带来一篇解决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>

本人已经测试通过了!

以上就是小编为大家带来的解决html-jquery/js引用外部图片时遇到看不了或出现403的问题的全部内容了,希望大家喜欢哦~

相关推荐:

php绘图之加载外部图片的方法,_PHP教程

请教用phpmailer发html格式邮件的外部图片问题

php绘图之加载外部图片的方法

以上就是html-jquery/js引用外部图片时看不了或出现403解决办法的详细内容,更多请关注其它相关文章!