【发布时间】:2013-01-13 18:31:51
【问题描述】:
我最近刚刚下载了 TideSDK,但遇到了一些问题。基本上,我想创建一个新窗口,使用外部链接(效果很好),然后注入样式表来修改窗口,就像你可以使用 chrome 扩展一样。
var newWindow = Ti.UI.createWindow({
id: "newwindow",
url: "http://www.example.com",
title: "New Window",
width: 1100,
minWidth: 400,
maxWidth: 1100,
height: 730,
minHeight: 500,
maxHeight: 730,
maximizable: true,
minimizable: true,
closeable: true,
resizable: true,
fullscreen: false,
maximized: false,
minimized: false,
usingChrome: true,
topMost: false,
visible: true,
transparentBackground: false,
transparency: false
});
newWindow.open();
我终其一生都无法弄清楚如何做到这一点。我尝试了以下几种变体:
var css = "<link type='text/css' href='app://style.css' />";
newWindow.document.getElementById('body').appendChild();
什么都没有附加到新窗口。事实上,无论我如何测试新窗口似乎都不会被识别为存在。有什么想法吗?
【问题讨论】:
-
你控制“新窗口”的来源吗?
-
不,这是一个运行服务的外部网站,我喜欢但讨厌布局。
-
除非您在自己页面的 iframe 中拥有外部网站(请参阅 this tutorial),否则这是不可能的。
-
没问题。我添加了我的解决方案作为答案。
-
经过大量研究,看起来由于同源策略,您只能在同一域上的 iFrame 上执行此操作:(
标签: javascript tidesdk