Running GUI program from within Javascript - javascript

Is there a way I can start a standalone GUI program from within my javascript code? What I intend is to display a button when in a particular website, which when clicked, opens up my GUI program and passes the URL to it, kinda like Internet Download Manager(IDM) does it.

If your app registers as a handler for specific URL schemes, then opening a link using one of those URL schemes should do.
For instance, if your app says it can handle the myscheme scheme, then opening myscheme:somedata URL should trigger opening that app.

Related

Is it possible for a link in an email to open a Chrome extension?

Is it possible to create a link that the user clicks (say in an email) which opens a Chrome extension that's already installed?
Or, put it in another way, is it possible to develop a Chrome extension that handles how a link is shown (e.g. inside Gmail.com or other sites), that whenever the user clicks it, the extension shows up instead of the user being directed to a site?
I've come across articles talking about custom protocols:
Custom protocol handler in chrome
But what if the extension is not installed, how do you fall back to HTTP?
http://mywebsite.com/somevalue
This could easily be done with a webNavigation.onBeforeNavigate listener which listens for a specific URL. When the URL is encountered, it can cause a specific page within the extension to be opened instead.
Quickly prototyping this, the code could look something like (untested, may have errors):
chrome.webNavigation.onBeforeNavigate.addListener(function(details){
chrome.tabs.update(details.tabId,{url:chrome.runtime.getURL('/thePageIWant.html'});
},{url:[
{urlEquals:'http:/www.domain-for-my-extension.com/invokeMyExtension.html'}
]});
References:
chrome.webNavigation.onBeforeNavigate
chrome.tabs.update()
runtime.getURL()

Opening Custom Protocol in FireFox Browser..!

I have created a custom Protocol myapp: just like mailto: which opens one exe at client side using JavaScript. So, whenever that JavaScript I call there opens a dialog box asking for selecting the application through which I want to open.
I just wanted to set the default application through which it opens in the code and doesn't open that dialog box. I know that I can manually change from always ask to set default in setting of Mozilla Browser, but I wanted it through Code. so that user does not have to do any thing.
Is it possible? If yes, please guide me how I can achieve this.
You cannot set such settings from an unprivileged webpage, that would be a huge security issue.
What you can ask the user from a webpage is to register a web application as a custom protocol handler, but not an exe. However, if that exe is written by yourself, you might just register it as a protocol handler within the OS.

How to download a file with WebClient if it is being served by javascript

I am writing an automated UI test solution based on Selenium WebDriver. I need a browser-independent method that can achieve file downloads.
My method, which relies on the System.Net.WebClient class, can successfully download files from a site if there is an attribute (such as href or src) from which to infer the file location.
However, I am having issues when the element that would normally hold the reference has no pointer to a file. Instead, this element has a CSS class that is tied to a Javascript click event. When the element is clicked, Javascript triggers a window.open action on a dynamically-created link.
Any ideas on how can I successfully capture that file reference from my C# code?
If I understand you correctly, you are building the client application and the server behavior is beyond your control. You want to mimic the following behavior of a real browser:
The client navigates to a URL.
The client clicks on a link (or other element) which triggers a
JavaScript function.
The JavaScript function redirects the client to the correct URL for
downloading an asset.
The client downloads the asset.
You cannot do this with the WebClient class, which does not expose any click behavior or any way to execute JavaScript. A WebClient instance is not a browser. It is just a class that provides a way to send data to and receive data from a given URL.
This does not answer your question directly, but there are arguments to be made that when using an automation tool you should stick to what can be done through the tool IE, you should use a browser to do whatever it is you need to do. If for some reason you just really need to download the result of that click event, but cannot do so through selenium, then you will probably need to use a headless browser. This question discusses some options you could use.
This question discusses some more options.

How to detect URL scheme and prevent the default navigation to that URL in phonegap hybrid application

I have the following requirement for my application (Android, iOS):
When the application launches it displays a login.html page (which is part of the application). After logging in, the application's webview should be occupied with home.jsp from an external domain. When user clicks on logout button in home.jsp it has to navigate back to login page . On click of logout when we usewindow.location.href="login.html" then it tries to find the page on xxx domain.
Is there a way to detect this navigation URL and override the URL from javascript or phonegap properties in the application?
When I inspect window.location.href in an android emulator I get file:///android_asset/www/index.html
But I think Nathans idea of moving it to the server is a good one. You could also have one on the device if you really need to. (PErhaps you should ask the person specifiying the app achitecture how they would do it :) )
The answer is going to vary depending on how you've implemented the mentioned WebView where home.jsp is being displayed in. You did not provide any code or any specific information so the answer is going to be the same - somewhat vague...
If you've opened a new WebView, then you can't control it from JavaScript. You'll need to control it via Java or Objective-C code (you did not mention which environment you're developing for...).
For example, if you'll look in the your-app\android\native\src\com\your-app\your-app.java file, you'll see how the native layer loads the application's index.html file after the Worklight JavaScript framework has been loaded.
Similarly, you could re-use this approach in your own application to close and re-load login.html.
If you're in fact doing the mentioned re-direct from the comments, meaning you're re-using the current webview but replacing its content with external content, then I think it is expected that you've lost the context of the application, and when looking for login.html - it doesn't find it... because you've moved from app-context to web-context. They do not know each other.
I think you should not do this re-direct. Instead, you need to open a new WebView using a Cordova plug-in, and in this new WebView to display your external content.
In this Overlayed WebView, you can detect any urls that are clicked on and if the sign-out URL was detected, then close the WebView.
You can see parts of this in action in the Integrating server-generated pages in hybrid applications tutorial and accompanying sample project.
In the sample project, you can see the functions provided (where you can add yours) in android\nativeResources\src\com\IncludeExternalPages\IncludeExternalPages.java.

App id for facebook like button for a page?

I can't be signed out if I want to get a like button for a facebook page. Yet, if I sign in, generated code adds an "appid". It shows me a list of facebook apps but there's no choice for making a button NOT for one of those apps. I just want a button for a regular facebook company page.
Is this something new or a weird bug?
Using the code that this gives me, then throws a warning in console:
"Given URL is not allowed by the Application configuration.: One or more of the given URLs is not allowed by the App's settings. It must match the Website URL or Canvas URL, or the domain must be a subdomain of one of the App's domains."
This seems to imply that I need to make an app just to use a like button, which makes no sense.
There is no alternative. You have to create a new app for this purpose. Or using app id of any of the existing app on that page will also work fine. Anyways all the apps on the page shares same page like.

Categories

Resources