Javascript code to force html page to open in Chrome browser? - javascript

We are using Google Apps at our company and everyone has Chrome installed on their computers. The problem is that we still have to use IE for certain things. I have a few html files on our intranet site that link to Google Docs, but it's opening in an IE browser. I need it to open a Chrome browser so the user doesn't have to sign in each time they open the file. I only have control of the html files settings so is there any way to use Javascript to force a window to open in Chrome?
Thanks!

I believe that if you're using IE you can use ActiveX to open up specific programs.
For instance try looking at 'new ActiveXObject'
You must explicitly allow this however as IE confirms if you want to allow it to be executed.
function loadProg(path){
var active = new ActiveXObject("WScript.Shell");
activeX = active.Run(path);
}
If you know the direct file path use this like
loadProg(path);
More specifically like
window.onload = function(){
loadProg("\"C:\\Program Files (x86)\\Guitar Pro 5\\GP5.exe\"");
};
I don't know the path to Chrome so i used something else instead.

Check if current browser is chrome:
var is_chrome = navigator.userAgent.toLowerCase().indexOf('chrome') > -1;
if not, alert user to show a message.

Are you asking if you can open a Chrome window from Javascript in an IE window? If so, then no, this is not possible. Javascript code in browsers run within a very strict sandbox that would not permit you to make any system calls. Opening a Chrome window from IE would effectively require you to execute chrome.exe on the client's machine. I'm sure you can see how this ability, if granted, could be misused to execute malicious exe's on the client' system.

I am quite sure that the best you can do using JavaScript is show a message to the user and tell them to open the file in Chrome instead. JavaScript does not have the right to execute an external application such as Chrome. See http://www.w3schools.com/js/js_browser.asp for information about detecting the browser using JavaScript.

Related

Can I open a URL in Chrome using JavaScript from Edge?

My company is using Windows Edge as our default browser (so our intranet home page is loaded in Edge). Some external links in our intranet can be open/print from Chrome without any problem, however, the issue begins if the URL is open from Edge.
Can we use JavaScript to force certain links to be open on Chrome from Edge?
I tried
var shell = new ActiveXObject("WScript.Shell");
shell.run("Chrome http://...");
I got ActiveXObject is not defined.
You can't use Javascript to do that. For security reasons, Javascript is sandboxed in your browser.
See this question for more info.
There are plugins that can do that, but this would require installing them on everyone's computer.
ActiveX is not supported in Edge. So no, that won't work. And, since JavaScript alone is not allowed to access OS resources, you won't be able to accomplish this.

Open a link in a specific browser

I have a web application which runs on all browsers but there is a link to another application which can only run in Internet Explorer. How I can force browser to open this link in a new IE browser when my application running in other browsers such as chrome? Should this piece of code written in server side or client side?
You can't force the client to launch a different browser like you're asking.
What I would suggest is to have your application test when it is launched to see if it is currently running in IE. If it isn't, it should issue an error message stating something like: "This application requires Internet Explorer. Please reopen in IE." Then have it stop there.
Most probably, using resources of JavaScript and HTML5, you cannot run applications on end user's computer. Moreover, it sounds incorrect in terms of security and usability.
The best thing you can do is to write a message like "Open this link in IE" near your link.
At the final page, you can detect a user's browser and, in case it is not an IE, show him a message "Unfortunately, this web-page works only with IE. Please, open it in IE".
By the way, could you tell us, why your page is not working in other browsers? Probably, we will find a proper answer there.

Weinre how to add new targets?

Hello I am new to Weinre and I need to debug my website which seems to act strange when opened using an IOS platform.
So I am using Weinre to debug it. I installed the tool and tested it running with the demo targets in the server itself.
Now I need to add my website as a target and run it with an iphon (or ipad) and debug it with Weinre. I don't know how to add my website as a target, I cannot manually add the
<script src="http://123.456.7.89:8080/target/target-script-min.js#anonymous"></script>
script (do not have permission to manually change the page). so How can I do my debugging with Weinre?
Thanks
You can try using a bookmarklet. The main weinre server page actually has a bookmarklet in it, for itself, that you should be able to use directly, if you can figure out how to set up a bookmarklet for your device. This seems to change release-release for mobile browsers, so you might want to do a google search on "bookmarklet" and your device's name or the OS release, to see if anyone has any tips.

Is it possible to open Internet Explorer window from Firefox? [duplicate]

Our Web application is based on IE9, which means only IE9 can open the pages in our site. We'll prevent user to browse our site when their browser is not IE9.
But sometimes we had to send a link to user's email box to complete some actions and they will open the link directly with their default browser, the problem is here, if the default browser is not IE9 then they can't open the link, they have to copy the link to IE9. Our user don't want do this manually, they want open the link in IE9 directly no matter what the default browser is.
I have tried using ActiveXObject, but it only works in IE. I want have a script which can open IE browser in Firefox/Chrome page.
It sounds like you want to have a link in an email that activates a specific program on the user's computer rather than the program that they've identified should be used (e.g., their default browser). I don't believe you can do that.
You can install "protocol handlers" in both Chrome and Safari (I suspect Firefox as well), which would let you send a link like ie://example.com/path/to/app. Your protocol handler would launch IE and take you to the relevant site. (Apple does this with iTunes.) But your users would have to install the handler (and, of course, you'd have to write it).
An easier answer might be to have the users install any of the ubiquitous "open in IE" add-ons/extensions that exist for Chrome, Firefox, etc. They follow the link, then choose "open in IE" from some kind of menu. (If they're using webmail, they may even be able to right-click the link and choose that line item, depending on the extension.)
Side note: Obviously, though, barring it being impossible I'd recommend making your application compatible with Chrome and Firefox.
No you can't do it..
but there is some alternatives:
Install your users IE tab:
FireFox - http://lifehacker.com/135297/internet-explorer-in-a-firefox-tab?tag=softwarewebpublishing,
Chrome - https://chrome.google.com/webstore/detail/hehijbfgiekmjfkfjpbkbammjbdenadd
Use a batch file that will launch your link in explorer.
use this Firefox plugin makes it possible to use (host) ActiveX controls in Firefox - http://code.google.com/p/ff-activex-host/
instead of ActiveX try using Netscape Plugin Application Programming Interface (NPAPI) - a cross-platform plugin architecture used by many web browsers.
Similar as with a batch file, you may create a link file to the page you need using the ".website" file extension with IE, which is configured in windows by default to open with ie. Put it in your webserver public folder and then add a link to that file in your website
You don't have to write code to create a custom protocol handler in Windows. See this page for how to define one in the registry.
You can use User agent switcher for chrome or firefox
For Chrome :
https://chrome.google.com/webstore/detail/user-agent-switcher-for-c/djflhoibgkdhkhhcedjiklpkjnoahfmg
For Firefox :
https://addons.mozilla.org/en-US/firefox/addon/uaswitcher/

Enable and Popup blocker in IE

I wrote a scripting logic in using ActiveX. When the application runs it is blocked by popup blocker. When I enabled it works fine, but I want to enable the popupblocker using JavaScript (especially in IE).
Obviously a website cannot modify the popup blocker settings. And that's a good thing.
You should avoid using ActiveX Controls because it is only supported by IE. Trying running your page on Firefox and it won't work.
Now the actual problem -
Firstly you need to understand what ActiveX Objects are used for? They basically allow a web application to interact with the client machine. For example it can use resources on my local hard drive. This is a security risk. So IE gives a warning for the same. You may disable it in your browser by going to Tools-> Internet Options -> Security Tab. Click "Custom Level" and change all the boxes with ActiveX text in it to "Enable".
But it will still show up in your client browsers.
So the point is try finding an alternative for it.
Hope this helps!
You cant. What you could do is have a message on screen which requests the user to turn off the popup blocker .

Categories