【发布时间】:2012-10-06 21:56:52
【问题描述】:
在 android phonegap 应用程序中,我需要使用 javascript 或 jquery 从 index1.html 获取 index2.html 的脚本。
这里是index1.html代码:
function nextpage(){
$.get('index2.html', function(data) {
$('#div').html(data);
alert('Load was performed.');
});
}
<input type="button" value="button1" onclick="nextpage()"/>
<div id="div"></div>
这里是 index2.html 代码:
function return1()
{
alert("welcome to index2.html");
var data={ "firstName": "John", "lastName": "Doe", "age": 25 };
}
<input type="button" value="welcome" onclick="return1()"/>
从这段代码中,我从 index2.html 中获得了“欢迎”按钮,并附加在 index1.html 的 #div 中。但我需要在 #div 中附加 return1() 并需要获取警报(“欢迎来到index2.html")。那是html页面功能响应。怎么做。请帮助我。提前谢谢。
【问题讨论】:
-
追加后需要调用return1()函数,你会得到警报。
-
感谢Roopchand。不附加到div,如何调用return1()
-
首先需要追加index2.html数据脚本,然后才能调用return1()函数,不追加不能使用其他页面脚本。
标签: android jquery html cordova