attr在其他域的图像不工作在科尔多瓦
问题描述:
我想动态地显示混合应用程序上的图像。我的意思是图像位于服务器上,我正在Cordova应用上显示它们。attr在其他域的图像不工作在科尔多瓦
我在头部添加了cordova和jquery。 这是代码。
var pics = "http://www.test.com/img/53_20160713104002.png";
document["profile-pic"].src = pics;
$("#profile-pic").attr("src", pics);
这里是html代码。
<a href="profile.html" data-original-title="" title="">
<img width="35" height="30" id="profile-pic" class="profile img-circle" name="profile-pic" /></a>
请告知我做错了什么。
编辑:这似乎是问题是由于跨域。我有白色列出配置文件中的域。
答
感觉像jQuery不适用于Cordova应用程序。尝试使用:
var pics = "http://www.test.com/img/53_20160713104002.png";
document["profile-pic"].src = pics;
document.getElementById("profile-pic").setAttribute("src", pics);
如果上面的代码有效,那么您必须找出为什么jQuery不在Cordova中工作。
一些指点下一个问题:
它似乎工作:https://jsfiddle.net/8jwqL6s4/ – Alvaro
它是在浏览器中正常工作,而不是在移动应用程序或模拟器。 – Ironic
@CalculatingMachine你可以检查jQuery是否在移动设备上工作?你使用什么版本? –