【问题标题】:Wouldn't display image on mobile不会在手机上显示图片
【发布时间】:2018-01-18 10:00:07
【问题描述】:

我有一个页面....http://kingola.com/test.html 我正在为我的移动应用程序工作,但由于某种原因,图像没有显示在我的 Android 移动浏览器上,但我在我的 Firefox 上看到它马克。

另外...由于某种原因,它在 IE 中不起作用。

代码:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    <link rel="stylesheet" type="text/css" media="all" href="style.css" />
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js" ></script>
    <title>Reading XML with jQuery</title>
     <script>
        $(document).ready(function(){
            $.ajax({
                type: "GET",
                url: "http://kingola.com/podcast/",
                dataType: "xml",
                success: function(xml) {
                    $(xml).find('item').each(function(){
                        // var id = $(this).attr('guid');
                        var title = $(this).find('title').text();
                        var url = $(this).find("enclosure").attr('url');
                        var description = $(this).find('description').text();
                        var img = $(this).find("itunes\\:image").attr('href');
                        $('<div class="items" id="link_"></div>').html('<a href="'+url+'">'+title+'</a>').appendTo('#page-wrap');
                        $('<div class="brief"></div>').html(description).appendTo('#page-wrap');
                        $('<div class="image"></div>').html('<img src="'+img+'">').appendTo('#page-wrap');
                        $('<div class="ima-link"></div>').html(img).appendTo('#page-wrap');
                    });
                }
            });
        });
     </script>
</head>
<body>
    <div id="page-wrap">
        <h1>Reading XML with jQuery</h1>
     </div>
</body>
</html>

【问题讨论】:

  • 图片不显示是什么意思?是图像根本没有加载还是它已经加载但图像源被破坏了?当我看到您的演示时,Chrome Mac 中没有加载任何图像。
  • 图片不显示。它应该被加载。在火狐上测试看看。
  • 让它工作。多谢你们。这有帮助。 stackoverflow.com/questions/9625487/…

标签: javascript html css mobile web


【解决方案1】:

你的来源没有被定义在那里没有显示,你可以试试这个

$('<div class="image"></div>').html('<img src="'+img+'">').appendTo($("#page-wrap"));

【讨论】:

    【解决方案2】:

    img的变量未定义,因为节点的选择器错误,试试这个

    var img = $(this).find("image").attr('href');    
    

    因为节点的名字是image,所以itunes就是这些节点的命名空间

    【讨论】:

    • 也已修复,但现在它们都不起作用。甚至连曾经是唯一有效的 Firefox 也没有。
    • 现在可以在 Safari 和 Mobile 上使用,但图像在 Firefox 和 IE 上不显示,仍然是空白的。 :(
    猜你喜欢
    • 1970-01-01
    • 2014-03-15
    • 2014-05-14
    • 1970-01-01
    • 1970-01-01
    • 2019-10-11
    • 1970-01-01
    • 2019-05-02
    • 1970-01-01
    相关资源
    最近更新 更多