我是phonegap app开发的新手。在我的应用程序中,我使用以下脚本在我的html页面中嵌入了Twitter时间轴提要:
<script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0],p=/^http:/.test(d.location)?'http':'https';if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src=p+"://platform.twitter.com/widgets.js";fjs.parentNode.insertBefore(js,fjs);}}(document,"script","twitter-wjs");</script>
脚本工作正常,它也给出了结果。以下是截图:
但是,当点击图片链接或图片时:如下所示,它会打开空白: 这是链接:
我尝试在手机浏览器上打开链接,效果很好。但是,同样不适用于应用程序。请帮忙。
更新
这是我的html页面:
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>info</title>
<link href="jquery-mobile/jquery.mobile.theme-1.0.min.css" rel="stylesheet" type="text/css"/>
<link href="jquery-mobile/jquery.mobile.structure-1.0.min.css" rel="stylesheet" type="text/css"/>
<link href="themes/f.css" rel="stylesheet" type="text/css">
<link href="styles/dst_mobile.css" rel="stylesheet" type="text/css">
<link href="styles/jquery.zrssfeed.min.js" rel="stylesheet" type="text/css">
<link href="styles/jquery.zrssfeed.css" rel="stylesheet" type="text/css">
<script src="jquery-mobile/jquery-1.6.4.min.js" type="text/javascript"></script>
<script src="jquery-mobile/jquery.mobile-1.0.min.js" type="text/javascript"></script>
<script src="phonegap.js"></script>
<script src="code/jquery.zrssfeed.min.js" type="text/javascript"></script>
<!--<script type="text/javascript">
$(document).ready(function () {
$('#news').rssfeed('http://dstinc1913.wordpress.com/category/News/feed/', {
limit: 10,
});
});
</script>-->
</head>
<body>
<div align="center">
<div data-role="page" id="info" data-theme="c">
<div data-role="header" data-theme="a">
<h1>News</h1>
<a href="index.html" data-icon="home" class="ui-btn-right" rel="external">Home</a>
</div>
<div data-role="content">
<div><a class="twitter-timeline" href="https://twitter.com/DSTinc1913" data-widget-id="350541068783210496">Tweets by @DSTinc1913</a>
<script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s) [0],p=/^http:/.test(d.location)?'http':'https';if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src=p+"://platform.twitter.com/widgets.js";fjs.parentNode.insertBefore(js,fjs);}}(document,"script","twitter-wjs");</script>
</div>
</div>
</div>
</div>
</body>
</html>
答案 0 :(得分:0)
这是Fiddle. 我没有改变代码,它为我工作!! ? 这是什么问题!?
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>info</title>
<link href="jquery-mobile/jquery.mobile.theme-1.0.min.css" rel="stylesheet" type="text/css"/>
<link href="jquery-mobile/jquery.mobile.structure-1.0.min.css" rel="stylesheet" type="text/css"/>
<link href="themes/f.css" rel="stylesheet" type="text/css">
<link href="styles/dst_mobile.css" rel="stylesheet" type="text/css">
<link href="styles/jquery.zrssfeed.min.js" rel="stylesheet" type="text/css">
<link href="styles/jquery.zrssfeed.css" rel="stylesheet" type="text/css">
<script src="jquery-mobile/jquery-1.6.4.min.js" type="text/javascript"></script>
<script src="jquery-mobile/jquery.mobile-1.0.min.js" type="text/javascript"></script>
<script src="phonegap.js"></script>
<script src="code/jquery.zrssfeed.min.js" type="text/javascript"></script>
<!--<script type="text/javascript">
$(document).ready(function () {
$('#news').rssfeed('http://dstinc1913.wordpress.com/category/News/feed/', {
limit: 10,
});
});
</script>-->
</head>
<body>
<div align="center">
<div data-role="page" id="info" data-theme="c">
<div data-role="header" data-theme="a">
<h1>News</h1>
<a href="index.html" data-icon="home" class="ui-btn-right" rel="external">Home</a>
</div>
<div data-role="content">
<div><a class="twitter-timeline" href="https://twitter.com/DSTinc1913" data-widget-id="350541068783210496">Tweets by @DSTinc1913</a>
<script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s) [0],p=/^http:/.test(d.location)?'http':'https';if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src=p+"://platform.twitter.com/widgets.js";fjs.parentNode.insertBefore(js,fjs);}}(document,"script","twitter-wjs");</script>
</div>
</div>
</div>
</div>
</body>
</html>
编辑:使用此代码在childbrowser中打开链接。这可能会有所帮助。
<!DOCTYPE html>
<html>
<head>
<title>InAppBrowser.removeEventListener Example</title>
<script type="text/javascript" charset="utf-8" src="cordova.js"></script>
<script type="text/javascript" charset="utf-8">
// Wait for device API libraries to load
//
document.addEventListener("deviceready", onDeviceReady, false);
// Global InAppBrowser reference
var iabRef = null;
function iabLoadStart(event) {
//alert(event.type + ' - ' + event.url);
}
function iabLoadStop(event) {
alert(event.type + ' - ' + event.url);
}
function iabLoadError(event) {
alert(event.type + ' - ' + event.message);
}
function iabClose(event) {
//alert(event.type);
iabRef.removeEventListener('loadstart', iabLoadStart);
iabRef.removeEventListener('loadstop', iabLoadStop);
iabRef.removeEventListener('loaderror', iabLoadError);
iabRef.removeEventListener('exit', iabClose);
}
// device APIs are available
//
function onDeviceReady() {
}
function inappbrowser()
{
iabRef = window.open('http://google.com', '_blank', 'location=yes');
iabRef.addEventListener('loadstart', iabLoadStart);
iabRef.addEventListener('loadstop', iabLoadStop);
iabRef.removeEventListener('loaderror', iabLoadError);
iabRef.addEventListener('exit', iabClose);
}
</script>
</head>
<body>
<h1>
THis is demo for the inappbrowser
<button onclick="inappbrowser()" type="submit">Click me</button>
</h1>
</body>
</html>