how can I use JsxSetter?

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

how can I use JsxSetter?

webb

Dear Sir,
I have some questions, the screen.java in Htmlunit, the value of Height is 768,
the value of Width is 1024, but wo want to change it when the WebClient creating,
I want to set some parameters of the screen, what should I do?
I'm looking forward to your reply soon.
Sincerely yours,
webb


------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, SlashDot.org! http://sdm.link/slashdot
_______________________________________________
Htmlunit-user mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/htmlunit-user
Reply | Threaded
Open this post in threaded view
|

Re: how can I use JsxSetter?

asashour
Hi,

@JsxSetter is meant to be called from JavaScript.

However, you can use the internal API, by something like:

            HtmlPage page = webClient.getPage(some_url);
            HTMLDocument document = (HTMLDocument) page.getScriptableObject();
            Screen screen = document.getWindow().getScreen();
            screen.setWidth(1234);

Hope that helps,
Ahmed


From: webb <[hidden email]>
To: htmlunit-user <[hidden email]>
Sent: Wednesday, March 1, 2017 3:26 AM
Subject: [Htmlunit-user] how can I use JsxSetter?

Dear Sir,
I have some questions, the screen.java in Htmlunit, the value of Height is 768,
the value of Width is 1024, but wo want to change it when the WebClient creating,
I want to set some parameters of the screen, what should I do?
I'm looking forward to your reply soon.
Sincerely yours,
webb

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, SlashDot.org! http://sdm.link/slashdot
_______________________________________________
Htmlunit-user mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/htmlunit-user
Reply | Threaded
Open this post in threaded view
|

Re: how can I use JsxSetter?

webb
Ahmed, Thank you for your review! but I want to set the Screen before got response, Because before this javaScript had got the Screen parameters. is there a way I can set? thank you again
Reply | Threaded
Open this post in threaded view
|

Re: how can I use JsxSetter?

asashour
Hi,

An option has been added in WebClientOptions to get/set the screen width/height.


Enjoy,
Ahmed

From: webb <[hidden email]>
To: [hidden email]
Sent: Wednesday, March 1, 2017 9:42 AM
Subject: Re: [Htmlunit-user] how can I use JsxSetter?

Ahmed, Thank you for your review! but I want to set the Screen before got
response, Because before this javaScript had got the Screen parameters. is
there a way I can set? thank you again


------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, SlashDot.org! http://sdm.link/slashdot
_______________________________________________
Htmlunit-user mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/htmlunit-user
Reply | Threaded
Open this post in threaded view
|

Re: how can I use JsxSetter?

webb
that's greate! thanks a lot.