2013-07-29 35 views
1

更新3WT可以将网页作为主页的一部分呈现吗?

user52875也有一个很好的答案,Can WT present web pages as part of the host page?它使用HTML,实际上是比JS来得容易很多。给你+1好先生。

更新2

想通了,工作代码波纹管。您需要在JavaScript中使用iframe来嵌入另一个页面。 IP地址是本地网络上运行带有一些内容的WT服务器的另一台PC,我能够连接并查看WT服务器的内容。此外,出于某种原因,iframe无法连接到浏览网站,如谷歌或雅虎。虽然我确信在某个地方还有一个单独的问题。

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 I帧的。 Javascript并不是我的强项,但我已经使用WT doJavaScript()命令(Embedding Ventus in WTUsing 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 

所以,我正在尝试做的是不离开主机页面呈现不同页面的内容。这可能吗?我一直在阅读文档和浏览widget画廊,但到目前为止还没有发现任何与将远程内容嵌入到您自己的页面中有关的内容。我的长期目标是将锚点连接到同一网络上另一台PC的IP地址,并将在该PC上运行的WT服务器的内容呈现在我自己的主机页面中,而不会离开它。预先感谢任何帮助!

回答

1

这里有一个类似的问题和答案。希望能帮助到你。

http://www.mail-archive.com/[email protected]/msg01578.html

+0

说明不是很清楚,认为他们确实可以将网页加载到WT容器中并将其显示在页面上。我该如何使用这个