Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/179.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
使用javascript实现Pinterest时出错_Javascript_Android_Cordova_Pinterest - Fatal编程技术网

使用javascript实现Pinterest时出错

使用javascript实现Pinterest时出错,javascript,android,cordova,pinterest,Javascript,Android,Cordova,Pinterest,我正在phonegap android应用程序中实现Pinterest。我使用的代码如下: <html> <head> <title>PINTEREST</title> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/> <meta name="viewport" content="width=device-width,i

我正在phonegap android应用程序中实现Pinterest。我使用的代码如下:

<html>
<head>
    <title>PINTEREST</title>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <meta name="viewport" content="width=device-width,initial-scale=1.0,maximum-scale=1.0,user-scalable=no"/>
   <meta name="layout" content="mobile"/>
    <meta name="apple-mobile-web-app-capable" content="yes"/>
    <meta name="apple-mobile-web-app-status-bar-style" content="black"/>
</head>
<body>
<a data-pin-config="above" href="https://pinterest.com/pin/create/button/?url=http%3A%2F%2Fwww.flickr.com%2Fphotos%2Fkentbrew%2F6851755809%2F&media=http%3A%2F%2Ffarm8.staticflickr.com%2F7027%2F6851755809_df5b2051c9_z.jpg&description=Next%20stop%3A%20Pinterest" data-pin-do="buttonPin" ><img src="https://assets.pinterest.com/images/pidgets/pin_it_button.png" /></a>
<script type="text/javascript" src="https://assets.pinterest.com/js/pinit.js"></script>
</body>
</html>

品特烈
它在浏览器中工作正常,但当我将其安装到Android设备上时,我会收到如下警告:

发生网络错误(file://assests.pinterest.com/pidget.html)#via=文件%3A%2F%2F%2F(资源%2Ftest.html&type=pidget)

是因为

<script type="text/javascript" src="https://assets.pinterest.com/js/pinit.js"></script> 


但我必须使用它。请帮助我解决此问题。

您可以将资产下载到本地。否则,在没有网络连接的情况下,它不会在手机上显示任何内容。使用其他网站的资源也可能是一个坏主意,请参阅。

您的应用程序可能没有此功能。检查它是否包含在
AndroidManifest.xml

中。我通过异步加载pinit.js解决了这个问题。我用的是:

 <script type="text/javascript">
(function (w, d, load) {
 var script,
 first = d.getElementsByTagName('SCRIPT')[0],  
 n = load.length,
 i = 0,
 go = function () {
   for (i = 0; i < n; i = i + 1) {
     script = d.createElement('SCRIPT');
     script.type = 'text/javascript';
     script.async = true;
     script.src = load[i];
     first.parentNode.insertBefore(script, first);
   }
 }
 if (w.attachEvent) {
   w.attachEvent('onload', go);
 } else {
   w.addEventListener('load', go, false);
 }
}(window, document,
 ['//assets.pinterest.com/js/pinit.js']
));    
</script>

(功能(w、d、负载){
var脚本,
first=d.getElementsByTagName('SCRIPT')[0],
n=荷载长度,
i=0,
go=函数(){
对于(i=0;i
您可以使用SocialShareing phonegap插件在Android上锁定一些东西。只需添加并添加一个按钮:

锁定它!