View Full Version : Get the params of window.open
brcontainer
12th February 2014, 18:19
I wonder if it’s possible to get the parameters passed by window.open, as the following example:
var params = "menubar=yes,location=yes,resizable=yes";
window.open("http://www.cnn.com/", "_blank", params);
I need to get params this menubar=yes,location=yes,resizable=yes in “c++â€.
Is it possible to do this using
class cutomWebView : public QWebPage
or
class cutomWebView : public QWebView
or something?
customWebPage.cpp:
QWebPage * customWebPage::createWindow(const QWebPage::WebWindowType type) {
qDebug() << type;
return new MainWindow()->createPage();//createPage is custom function
}
Infinity
12th February 2014, 18:33
What do you want to achieve?
If you want to extract the query string from a QString with HTML code, you can use the methods of the QString class or the QRegExp class.
To parse a query string you can use the QUrlQuery class.
brcontainer
12th February 2014, 20:17
@Infinity I'm trying to create a complete (yet unpretentious), browser already created almost everything (bookmarks, history, cookies).
But I realized that when using the window.open event, it is not possible to capture the parameters.
in my view should look something like this (this is an imaginary function):
QWebPage * customWebPage::createWindow(const QWebPage::WebWindowType type, const QString params) {
qDebug() << params;//show in console all params (if have)
if(params==""){//without params or <a href="" target="">
return parentWindow->addTab();//This function add tab in current window
}
const QStringList a = params.split(",");//split params
MainWindow *b = new MainWindow();
b->setParamsWindow(a);//my custom function, set params in window
b->show();//show window
return b->addTab();//This function add tab in "new" window
}
brcontainer
17th February 2014, 04:42
I am developing a browser, it will have support for tabs.
But I have a difficulty, QWebPage::createWindow does not differentiate window.open to <a href="" targert="">.
eg.:
<script>
var params = "menubar=no,location=no,resizable=no";
window.open("http://www.cnn.com/", "_blank", params);
</script>
and
<a href="http://www.cnn.com/" target="_blank">
are considered the same by QWebPage::createWindow
How to differentiate both?
When window.open I will create a window and when anchors will add a new tab.
brcontainer
21st February 2014, 04:13
Solution:
http://stackoverflow.com/a/21925144/1518921 :)
Powered by vBulletin® Version 4.2.5 Copyright © 2024 vBulletin Solutions Inc. All rights reserved.