I have a device, which uses JSP to create the webpage, to maintain itself. There are some onclick events, and I would like to get some information from this device via a stand alone application, which only connects via IP to this device, and get all the information.
So, is it somehow possible to get directly to the functions, which are normally triggered via onclick events, so that non-human programs can open these pages?
Thank you
Related
I'm trying to figure out a way to perform a trusted event programmatically in the browser.
https://developer.mozilla.org/en-US/docs/Web/API/Event/isTrusted
I know it says it's a readonly event but I figure there must be some sort of work around if the user really wants it. After all the browser/frontend is entirely client side so you should be able to manipulate it yourself if you so choose (via some option in the browser etc)
I came across this answer https://stackoverflow.com/a/53488689/3097821 but I can't figure out to to implement it.
It can either be a click or a keyboard event.
Can anybody help me out on this?
Web content cannot generate a trusted event under any circumstances -- that is the whole point. Some actions don't care if an event is trusted or not (clicking a link, for example), but some do need to distinguish between a legitimate user-triggered event and a synthetic one create by untrusted web content.
Web Extensions are assumed to be working on the user's behalf, so they are allowed to create trusted events.
I have build simple desktop application, which is loading content into webview element.
Now I am looking for some options how to resize application window based on some Javascript action called from DOM inside webview.
For example:
By default I am displaying some information related to the team of people using this Chrome application on their desktop. These data are being fetched from PHP application running on our servera rendered using HTML/CSS/jQuery.
Now I would like to render some form, which will give us options to edit this content directly inside Chrome application and store them in database, but the issue is, that by default is Chrome application very small: approx. 200x300px and at the moment, when I render this form I would need to resize whole application to approx. 300x500px and I have no idea how to achieve that.
I was browsing in Chrome apps documentation where i have found some info related to app.window, but I did not find a way, how to apply this into the real world app and execute such a commands via Javascript inside webview element.
Thank you for any ideas and suggestions.
You won't be able to do that from inside the webview. You are correct that chrome.app.window is the required API, but a webview-embedded page has no privileges to call it.
You'll need to communicate with your app's script, which has the necessary privileges. I would actually recommend using the "externally_connectable" method since it's for a specific site.
Once you've passed a message to the app page's script, you can resize the window with
chrome.app.window.current().innerBounds.setSize(width, height)
or, in case of a listener in the event page,
chrome.app.window.get(windowId).innerBounds.setSize(width, height)
Note that you can set the initial size when creating the window.
I've run into the problem where the contentDocument on an iFrame is not accessible to me because it's on a different domain, but I need to find some way to send touch events to elements within this iFrame in a UIWebView.
Basically the user can access pages like this one, and due to the user being unable to click on these manually (UIWebView is on a second screen using AirPlay mirroring) I need to be able to send click/touchstart/touchend etc events to elements on whichever page the user is accessing.
Is there any way to do this at all with Javascript? If not, is there any way to somehow extract the iFrame within UIWebView to get around this limitation?
You can do this using the postMessage API:
https://developer.mozilla.org/en-US/docs/Web/API/Window.postMessage
You will have do incorporate a messaging system between the two windows, handle the events to do what you want, you won't have DOM access, but you should be able to do that via events that trigger handlers in each window.
Is it possible for JavaScript to detect whether an application (such as BitTorrent) is installed and if so, can it can be launched by clicking on a link?
This is not Javascript, it works with handlers.
Handlers are in your browser and trigger events when a special protocol is clicked / called.
e.g.: if you open a magnet:// link, it will trigger the handler for magnet. And the handler is connected with the bittorrent application.
So:
first question: No
second question: Yes (with a handler [need to be installed in browser])
I'm writing an app which should load a website. After the website is loaded, I have to fire up a 2nd command to the web page, which is kind of Javascript scriptlet.
I did this manually in my browser and in generally it seems to work fine. They way I did it manually was I created two shortcuts in my browser:
the URL to this website (e.g. http://www.example.net/123456-e.aspx)
the shortcut to a Scriptlet which calls a function on this website (e.g. javascript:__doPostBack('Video_Info1$Rating_control1$lnk_star5','')).
I first click the URL shortcut and after its loaded, I fire up the 2nd shortcut.
But how can I do this in a C# application?
But, what I'm trying to do is quite the opposite I think.
I'd like to SEND a _postBack to an existing site.
I'm not writing my own site which contains a postBack control!
Let me explain a little in detail...
the site I'm loading in my app is an existing ASPX site in the web.
In this site, you'll find several _doPostback entries and in a browser, the postBack event (when I hit it manually within a bookmark/shortcut) will be send back and has its desired result (in this case, its assigning "5 stars" to tell everybody, that something is supergood ;-).
So, what I'd like to do is to write my C# App which will send this _postBack command every time I hit the OK button or some other events.
Just as it is with my link above
"javascript:__doPostBack('Video_Info1$Rating_control1$lnk_star5','')"
This is the bookmark I have on my browsers bookmark panel - a shortcut!
.... Just to be honest, its a kind of cheat, which will do an automatic voting on an external site...
My prob is now,... how can I send this _postBack straight to the site, to increase my stars?
I am not sure what exactly you are trying to achieve, The code which you are seeing (_doPastBack(..)) is actually going to invoke a server method (code in your codebehind of that page).
You can create a webpage and have an iframe and load your first page in that.The user will be able to click on any of the button and invoke the corresponding server code if there is one attached.
<html>
<body>
<iframe src="http://www.example.net/123456-e.aspx"></iframe>
</body>