我正在尝试遵循这篇文章,在这篇文章中他描述了使用
在本节中,他尝试描述如何从一个页面跳转到另一个页面。我正在试着看我是否可以做4级,但不知道如何做;这可能也是一个纯粹的JS问题。
> App.onLaunch = function(options) {
> alert("Hello!", function() {
> var helloDocument = getDocumentContents("http://localhost:8000/hello.tvml", function(xhr)
> {
> navigationDocument.dismissModal();
> navigationDocument.pushDocument(xhr.responseXML);
> });
> }); }有没有人帮忙,怎么做回调?
> App.onLaunch = function(options) {
> alert("Hello!", function() {
> var helloDocument = getDocumentContents("http://localhost:8000/hello.tvml", function(xhr)
> {
> navigationDocument.dismissModal();
> navigationDocument.pushDocument(xhr.responseXML);
> });
> }); }发布于 2015-09-15 23:49:42
要导航到其他页面,您需要将这些页面推送到堆栈上:
var parser = new DOMParser();
var newPageDocument = parser.parseFromString(NEW_PAGE_XML, 'application/xml');
navigationDocument.pushDocument(newPageDocument);要返回上一页,可以按遥控器上的菜单按钮或调用navigationDocument的popDocument方法:
navigationDocumemt.popDocument();假设getDocumentContents是一个从hello.tvml获取XML的方法,代码将如下所示:
App.onLaunch = function(options) {
getDocumentContents("http://localhost:8000/hello.tvml", function(response) {
var parser = new DOMParser();
var firstDocument = parser.parseFromString(response, 'application/xml');
navigationDocument.pushDocument(firstDocument);
});
}此外,不支持报警,但支持控制台。
https://stackoverflow.com/questions/32553565
复制相似问题