Results 1 to 5 of 5

Thread: Get the params of window.open

  1. #1
    Join Date
    Apr 2013
    Posts
    65
    Thanks
    4
    Thanked 3 Times in 1 Post
    Qt products
    Qt5
    Platforms
    Unix/X11 Windows

    Question Get the params of window.open

    I wonder if it’s possible to get the parameters passed by window.open, as the following example:
    Qt Code:
    1. var params = "menubar=yes,location=yes,resizable=yes";
    2. window.open("http://www.cnn.com/", "_blank", params);
    To copy to clipboard, switch view to plain text mode 

    I need to get params this menubar=yes,location=yes,resizable=yes in “c++”.

    Is it possible to do this using

    Qt Code:
    1. class cutomWebView : public QWebPage
    To copy to clipboard, switch view to plain text mode 
    or
    Qt Code:
    1. class cutomWebView : public QWebView
    To copy to clipboard, switch view to plain text mode 
    or something?

    customWebPage.cpp:

    Qt Code:
    1. QWebPage * customWebPage::createWindow(const QWebPage::WebWindowType type) {
    2. qDebug() << type;
    3.  
    4. return new MainWindow()->createPage();//createPage is custom function
    5. }
    To copy to clipboard, switch view to plain text mode 

  2. #2
    Join Date
    Oct 2012
    Posts
    132
    Thanks
    10
    Thanked 21 Times in 21 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows Android

    Default Re: Get the params of window.open

    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.

  3. #3
    Join Date
    Apr 2013
    Posts
    65
    Thanks
    4
    Thanked 3 Times in 1 Post
    Qt products
    Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Get the params of window.open

    @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):
    Qt Code:
    1. QWebPage * customWebPage::createWindow(const QWebPage::WebWindowType type, const QString params) {
    2. qDebug() << params;//show in console all params (if have)
    3.  
    4. if(params==""){//without params or <a href="" target="">
    5. return parentWindow->addTab();//This function add tab in current window
    6. }
    7.  
    8. const QStringList a = params.split(",");//split params
    9. MainWindow *b = new MainWindow();
    10. b->setParamsWindow(a);//my custom function, set params in window
    11. b->show();//show window
    12. return b->addTab();//This function add tab in "new" window
    13. }
    To copy to clipboard, switch view to plain text mode 
    Last edited by brcontainer; 12th February 2014 at 21:30.

  4. #4
    Join Date
    Apr 2013
    Posts
    65
    Thanks
    4
    Thanked 3 Times in 1 Post
    Qt products
    Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Get the params of window.open

    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.:

    Qt Code:
    1. <script>
    2. var params = "menubar=no,location=no,resizable=no";
    3. window.open("http://www.cnn.com/", "_blank", params);
    4. </script>
    To copy to clipboard, switch view to plain text mode 

    and

    Qt Code:
    1. <a href="http://www.cnn.com/" target="_blank">
    To copy to clipboard, switch view to plain text mode 

    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.

  5. #5
    Join Date
    Apr 2013
    Posts
    65
    Thanks
    4
    Thanked 3 Times in 1 Post
    Qt products
    Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Get the params of window.open


Similar Threads

  1. Replies: 2
    Last Post: 14th January 2013, 08:07
  2. Replies: 3
    Last Post: 23rd December 2010, 07:55
  3. slots with params problem
    By brantyou in forum Newbie
    Replies: 1
    Last Post: 15th September 2010, 06:36
  4. Replies: 0
    Last Post: 10th September 2010, 14:23
  5. Qt as only Gui Module (QMainWindow Params)
    By radex99 in forum Qt Programming
    Replies: 4
    Last Post: 30th August 2010, 19:13

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.