Greetings, all! I have hit a bit of a brick wall and was hoping that I could get some help. I'm trying to write a site that people can access with IE6+ that will allow them to click a link that will open a piece of software on their desktop (the run/save dialog is OK) that also contains variables. Thoughts, ideas? It should look something like this:
<html>
<head>App Launcher</head>
<body>
Primary ABCD
</body>
</html>
This is not possible, you will need to use third party application like Flash,Java applets but directly from html this is not allowed in the browser.
but you can create an exe file and tell the user to download it and run it to open the designated application and you can send the parameters that you want through that exe.
You can do this using an ActiveX Control. Once the user grant permission to execute the ActiveX, the .exe file can be executed on the client machine.
Edit:
Here is an example about how to do it:
<SCRIPT Language="JScript">
function runcmd() {
File="http://www.yoursite.com/your_executable.exe";
WSH=new ActiveXObject("WScript.Shell");
WSH.run(File);
}
</SCRIPT>
Run
But note that this will only work under IE. To produce the same effect on Mozilla browsers, Safari and others, just this will work:
Run
Both solutions will prompt the user to choose to run or not the application from the link. You can't force programs to run on the user's machine without his permission because its a security issue.
Hope this works for you =)
this will lead to huge security issues and therefore isn't possible trough plain HTML. You will need a java applet or something similar that where the user gets the choice to accept.
Related
someone knows how to open a program that is installed on the desktop from a web page, something like the onedrive option where from the web you can tell them to open a document and open word with that document or like when you open a torrent link ?
You basically have to download a file that is recognized by the program you wish to start. That program has to be pre-installed on the machine. The file should include instructions the program understand, and can execute.
In any case, this is quite fragile, and depends on many variables you have little control over, including the user, who might decline the download, or just save the file without opening it. So you should try a different approach to achieve what you want, than running a program on a user's computer.
We are currently looking at porting a enterprise silverlight application over to html5. The major roadblock that we have hit is the ability to open files from the user's local disk. Currently they have a document library which just links to files on their computer that they can open from within the app and view or print out. All that I read is that you can only access the local sandbox of the web app with the html5 file api's. We want to load these files from code.
Does anyone know of any workarounds to this?
Thanks
There is no way for html5 to access local file without user selection. But FSO: FileSystemObject works for IE and MAYBE could be regarded as a work around. But still there are some requirements to meet.
It is possible to use chrome's filesystem API to access files on a users local filesytem. So you'd have to be willing to make this a chrome only application.
Using java you can create a "Signed" applet which has access to the local filesystem. (if the applet is signed you can request filesystm permissions)
then there is a tutorial for accessing methods of your java code directly from javascript here: http://docs.oracle.com/javase/tutorial/deployment/applet/invokingAppletMethodsFromJavaScript.html
you should be able to perform something similar from silverlight.
There is no workaround in pure HTML5/Javascript. You need the use of plugins, such as Java or Silverlight (maybe you shouldn't port it after all). As for workarounds, HTML5 gives you an easy way drag and drop multiple files that you could transfer on the server and then display back to your users. Another workaround would be to install a custom agent (a software with only a tray icon) that would send the information about the current user "document library" to server and then again, you could display it back to the user.
Note: I've heard somewhere that browsers will eventually stop supporting plugins. http://www.howtogeek.com/179213/why-browser-plug-ins-are-going-away-and-whats-replacing-them/
Ya, I agree with Markain. However, if you were to limit your audience solely to chrome users, I daresay, you would most likely use some of your users. If Huazhihao is right, then your number of leaving customers should decrease but users who regularly use firefox won't be happy. Overall, I think that this will not work. Otherwise, there would be too many websites that trashed your hard driver (or at least wherever you have the rights to edit/delete files). I think it would be best if your product was setup to synchronize the file whenever an internet connection was detected and a change was made to the file. That way the user would not need to visit the website whenever the file was uploaded. If this is some kind of an error file, then it would be most beneficial if you were to make a link in the application that when clicked, would upload the file to the website and the website were to do whatever was necessary. If this is a purely online thing, then I don't see what business you would have looking through other peoples' files =-). Hope I helped!
I've written a software that customers will install on Windows Server, and I wrote a HTML page for installation guide. How do I create a link on HTML page that will invoke my .bat script as an administrator. The .bat script will handle installation for customers. HTML page will be run as a file, that is without any server (including local host). The .bat script, html page, and binary will be in the same folder. The folder could be anywhere on the Windows server (I don't know where customers will place the folder).
One way of doing this would be to use a combination of AJAX and a script to accomplish this.
I'm going to assume the use of jQuery and PHP (just because they're so common) for this example.
jQuery just makes it shorter and this functionality will be available in most/all languages.
Let's say you have a page like this:
<html>
<body>
<a id="foo" href="#">Install</a>
<script src="install.js"></script>
</body>
</html>
And your javascript looks like this:
$("#foo").on("click", function(){
$.post('install.php');
});
In your install.php file, you could have this:
<?php
exec("mybatch.bat");
or
<?php
exec("cmd.exe /c test.bat");
However
Please note that what you are wanting to do has security problems.
Only do this if you are sure the environment is a secure one.
Running as administrator
This is a very difficult thing to do without cooperation from the client computer.
You more or less have to be running PHP or whatever language is installed locally as administrator.
Also, if running a batch file from a POST request is a bad idea, running a batch file as administrator is even worse. Avoid this.
In internet explorer:
file://mydirectory/myfolder/mybatchfile.bat
Most browsers don't allow this functionality because it poses a huge security risk for a link on a web page to be able to run local files. Most of them have extensions that disable that security feature. I haven't tested any of them to see if they work, however.
Even when this happens, however, the .bat run will happen like a download. The browser will "download" the .bat file, then give the user the opportunity to save it or run it. Unless your batch file is doing the administration elevation within the file itself, the user will have to manually run it as administrator.
Please keep in mind that these safeguards exist for a reason, and going around them is not a good idea. At the end of the day, however, there is no way to make the browser execute that code on its own. (Thankfully so!) There are better ways of accomplishing these kinds of tasks.
If you wanted to provide more details on what you are trying to accomplish, i'm sure we could come up with a more secure of doing what you want to do.
I'm trying to get externally-situated csv data to load up in a script, but this fails I think due to browser same origin policy. I've spotted some relevant looking discussion on working around this using cross-document messaging, but to be honest I don't have a clue how to implement this. Grateful for advice on this or another workaround. The script below should print each data line to the browser console but fails.
<html>
<head>
<meta charset='utf-8'>
<script type="text/javascript" src="scripts/d3.v2.js"></script>
<title>CSV reader</title>
</head>
<body>
<script type="text/javascript">
d3.csv("http://www.quake.utah.edu/EQCENTER/LISTINGS/OTHER/Yell_Q32012TT.csv",
function(parseCoords) {
parseCoords.forEach(function(d) {
console.log(d);
});
});
</script>
</body>
</html>
If you are doing something like writing HTML and Javascript in a code editor on your personal computer, and testing the output in your browser, you will probably get error messages about Cross Origin Requests. Your browser will render HTML and run Javascript, jQuery, angularJs in your browser without needing a server set up. But many web browsers are programed to watch for cross site attacks, and will block requests. You don't want just anyone being able to read your hard drive from your web browser. You can create a fully functioning web page using Notepad++ that will run Javascript, and frameworks like jQuery and angularJs; and test everything just by using the Notepad++ menu item, RUN, LAUNCH IN FIREFOX. That's a nice, easy way to start creating a web page, but when you start creating anything more than layout, css and simple page navigation, you need a local server set up on your machine.
I have seen similar problems linking to a file in the drop box public folders area. (specifically https://dl.dropbox.com/u/101577503/D3-Tips-and-Tricks-Latest.pdf). The first time you click on the link from a web page, the downloading of the pdf fails, then refresh and it works. I don't know why it occurs, but I get the same result when I test your 'http://dl.dropbox.com/u/46043231/data/xy.csv' in Chrome. Is it also possible that even if it works first time that you will be stymied by cross domain limitations?
Question abandoned because it seems unanswerable. Will update if I find a solution at a later date.
I have a site, from which you can download an HTML file. This HTML file contains a form with hidden fields, which is right away posted back to the site using JavaScript. This is a way of allowing users to download to their own machine data that they edit on the site.
On some machines, you get an IE "yellow bar" when trying to open the file you saved. The "yellow bar" in IE is warning that the HTML is trying to run an Active X (which it is not, there is only JavaScript doing a submit() on a form). However if you receive the exact same HTML file by email, save it, and open it, you don't have this problem. (It looks like IE is putting some more constraint on what can be done in a HTML file you saved from web site.)
My question is: where can I find documentation on this IE security mechanism, and possibly how can I get around it?
Alex
The yellow bar is because your page is executing in the Local Machine security zone in IE. On different machines, the Local Machine security zone might be configured in different ways, so you can see the yellow bar on some machines and not see it on other machines.
To learn more about the IE's URL Security Zones, you can start reading here: http://msdn.microsoft.com/en-us/library/ms537183.aspx
Look here for details on the MOTW - Mark Of The Web
If you add this to your locally served pages, IE will not show the yellow bar.
http://msdn.microsoft.com/en-us/library/ms537628(VS.85).aspx
I am not usre about any specific documnet, but if you open the properties for the file in windows explorer on the general tab is the file blocked? if so click unblock and try again and see if you gte the same issue. This is typical security for files downloaded fom the internet.
Other than that i am afraid i dont know what else to suggest.
I don't 100% follow what your JavaScript is submitting to, but if you're submitting back to the original site from the downloaded copy you'll have a problem using JavaScript as all browsers treat cross-domain JavaScript as a security violation.
JavaScript isn't allowed to read or write to any site not on the current domain
As Franci had said it is becaue you are in the local machine security context and this allows scripts to create objects and execute code that could do harm to your PC. For example you can create a File System Object and perform tasks that an untrusted page shouldn't perform generally because it could be malicious in nature.
Have you tried changing the file name from yourname.html to yourname.hta to see if the security problem goes away?
More on HTML Applications (.HTA files): http://msdn.microsoft.com/en-us/library/ms536496%28VS.85%29.aspx