【发布时间】:2013-07-29 20:46:28
【问题描述】:
更新 3
user52875 也有一个很好的答案,Can WT present web pages as part of the host page?,它使用 HTML,实际上比弄乱 JS 容易得多。 +1 给你好先生。
更新 2
想通了,下面的工作代码。您需要在 javascript 中使用 iframe 在您自己的页面中嵌入另一个页面。 IP 地址是本地网络上的另一台 PC,它运行具有某些内容的 WT 服务器,我能够连接并查看 WT 服务器的内容。此外,由于某种原因,iframe 无法连接到浏览网站,例如 google 或 yahoo。虽然我确信在某个地方有一个单独的问题。
WText* text = new WText(root);
string command = string("var ifr") + " = document.createElement('iframe');" +
//"ifr.src = 'http://javascript.info';" + //Works
//"ifr.src = 'http://www.escapistmagazine.com';" +//Works
//"ifr.src = 'http://escapistmagazine.com';" + //Works
//"ifr.src = 'http://google.com';" + //Doesn't work
//"ifr.src = 'http://www.google.com';" + //Doesn't work
"ifr.src = 'http://12.3.45.678:8080/';" + //Works
"ifr.width = 1500;" +
"ifr.height = 700;" +
"document.body.appendChild(ifr);";
text->doJavaScript(command);
更新 1
这似乎需要使用带有 WT 对象的 JS iframe。 Javascript 不是我的强项,但我使用 WT doJavaScript() 命令(Embedding Ventus in WT 和 Using ACE with WT)做了一些应用程序的嵌入。如果我找到将页面嵌入 WT 的正确方法,我将进一步更新帖子。提前感谢您的帮助。
WText* text = new WText(root);
string command = ""; //TODO: Proper creation and use of JS iframe.
text->doJavaScript(command);
原帖
所以,我正在尝试创建一个小型 WT 应用程序,其中有一组锚点,或者一个文本框和一个用于输入和切换页面的按钮。基本设置是这样的:
WContainerWidget* root = wApp->root();
WAnchor* Google = new WAnchor("http://www.google.com/", "Google", root);
root->addWidget(new Wt::WBreak());
WAnchor* Yahoo = new WAnchor("http://www.yahoo.com/", "Yahoo", root);
root->addWidget(new Wt::WBreak());
Wt::WLineEdit* GotoBar = new Wt::WLineEdit(root);
Wt::WPushButton* GotoButton = new Wt::WPushButton("Goto address", root);
//TODO: Some kind of widget that will present the content of the anchors
// or the GotoBar
所以,我要做的是在不离开主机页面的情况下呈现不同页面的内容。这可能吗?我一直在阅读文档并浏览小部件库,但到目前为止还没有找到与将远程内容嵌入到您自己的页面相关的任何内容。我的长期目标是让锚点连接到同一网络上另一台 PC 的 IP 地址,并在我自己的主机页面中显示在该 PC 上运行的 WT 服务器的内容而不离开它。提前感谢您的帮助!
【问题讨论】:
标签: javascript c++ web embedding wt