i want to make a button in html page so that when a user click it an excel application get starts.
<button class="btn btn-primary" href="to popup excel sheet">click</button>
HTTP is a stateless protocol. What that means for you is that when your users download a file from the intranet via http, they are downloading a copy, rather than the original. Any changes they make will only appear in their copy, and then you end up with loads of copies of the same workbook with different, possibly overlapping changes. You don't want that!
And also ... how are your users even going to upload their changes?
You need to create a shared folder on your network and put the workbook there. You can then use the file:///SERVER/PATH/FILE.xls format in your <a /> links on your intranet to direct your user to the actual file on the server.
I would recommend you start by creating a simple html doc on your desktop to get familiar with the file:/// path format.
Eg
<html>
<head />
<body>
Click
<body>
<html>
save that in notepad and rename the extension from .txt to .html.
You can also type file:/// paths straight into windows explorer's address bar which allow for testing paths without resorting to the html document mentioned above.
UNFORTUNATELY! It seems that the browsers default behavior is to always download a link rather than open it (even if it is a local resource), so if you actually want to open it then you must resort to changing your browser intranet permissions to allow JS to access local resources, which then allows you to use the technique below.
This article (http://www.codeproject.com/Articles/113678/How-to-execute-a-Local-File-using-HTML-Application) uses
<script type="text/javascript" language="javascript">
function RunFile() {
WshShell = new ActiveXObject("WScript.Shell");
WshShell.Run("c:/windows/system32/notepad.exe", 1, false);
}
</script>
to open notepad. You can use command line arguments with Excel.exe (https://support.office.com/en-za/article/Command-line-switches-for-Excel-321cf55a-ace4-40b3-9082-53bd4bc10725) to tell it what the file path is...
Excel.exe "C:\PATH\Excel.xls"
Refer link: Open excel file through normal html link
Related
I Want to generate a link for my local woff file. With help of createobjectURL function, A link is created, however, the penalty is in the way of a blob. The URL lifetime is tied to the document in the window on which it was created. The URL runs only on my browser, and when I close relevant tab, the file disappears. So, I'm trying to find a way using js function which creates a perm link to uploaded local file. Currently I used .
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>URL.createObjectURL example</title>
</head>
<body>
<input type="file">
<file>
<p class="p">The URL of file is : </p>
</body>
<script>
var Element = document.querySelector('input');
var file = document.querySelector('file');
Element.addEventListener('change', function() {
var url = URL.createObjectURL(Element.files[0]);
file.src = url;
console.log(url);
var d=document.querySelector(".p");
d.textContent+=url;
});
</script>
</html>
It creates blob:https://www.example.com/123 however I require https://www.example.com/123. I also tried Base 64 encoding. It works but the file size, and speed becomes a drawback even when it is compressed.
You're asking for one thing but giving an example of another here.
I Want to generate a permanent link for my local woff file.
You can't generate a URL to file://etc/etc since:
Browsers don't expose information about the user's file system to JS
If you could get a URL like that, then the browser wouldn't let the webpage link to it.
Access to local files is heavily restricted.
I require https://www.example.com/123
If you want the file to be available on your website: actually upload it to the website! Right now, the file only exists on the user's disk and in the memory being accessed by their browser.
You have to send the data to a server (e.g. with an Ajax POST request) where you have a webservice which reads the request, extracts the file from it, stores the file somewhere, gives it a URL, and then sends the URL back to the browser.
Is it possible to run a newly created JavaScript file in a local workspace in the chrome developer tools console?
The workflow I'm trying to achieve is the one shown in this image:
I want to be able to create a new file in my workspace, run (or require or whatever) the file and be able to use it's functions and variables in the chrome developer console.
If I'm correct, this means running the script within the context of the webpage and adding the methods and variables to the window object?
Is their a way this can be done?
I could not find an automatic way to add a local file into the DOM context. The best solution I found so far:
Open your local workspace and the right file
Press CTRL + a (Select all)
Press CTRL + SHIFT + e (alternative: Right click with the mouse on the selected text and click on "Evaluate in Console")
Well, this is not much better than copy&paste but spares a few key presses/mouse clicks.
You can create a plain html file like this with your javascript file in the script tag.
Then you should be able to get all your methods in the developer console.
You can define a method in your page to dynamically add javascript to the page and then call it from the console.
For example if you had a method like this:
function loadJs(filename) {
var tag=document.createElement('script');
tag.setAttribute("type","text/javascript");
tag.setAttribute("src", filename);
document.getElementsByTagName("head")[0].appendChild(tag);
}
then you can use that method from the console to load your javascript files.
As an example:
Step 1: we create one folder "TestJS_folder" and it contains two files.
First file is index.html
Second file is test.js file.
Content of html file can be :
<html>
<head>
<title>Test JS in Chrome</title>
</head>
<body>
<script src="test.js"></script>
</body>
</html>
Step 2: Now you can import/open this test.js file in VSCode or any editor. And you can code the js file from IDE and click on index.html , it will open the html file on browser and you can go to Inspect-> console to check the logs based on your use case.
How do you get html files in dropbox to open in a new window as an application, rather then opening it in the preview window. AgileBits the creators of 1Password for mac have a html page that they upload to dropbox and when open on dropbox's website it opens in a new tab and runs directly from your dropbox as an application.
I have tried a number of things and have not been able to recreate this, nor can I find any documentation on dropbox that says how to do it. If I take there html file and copy it, it works as expected. If I copy the content of the html into a new file, it only opens in a preview window. If I rename there file it no longer works, I search around for hidden .files and messed around with those but none of them seem to affect anything.
It might be just me but I think your question is phrased badly, however if I understand you correctly you want to essentially HOST a webpage/site from DropBox.
This is still possible, despite them phasing out the public folder in Aug 2012.
New accounts registered after this date need to manually enable the public folder by going here: http://www.dropbox.com/enable_public_folder
Inside the Public folder you can store almost anything (including HTML files) that can be accessed directly with an absolute URL.
You want to open the https://dl-web.dropbox.com/get/*folders*/*file.ext*?_subject_uid=*9999999*&w=*abcdefghijklmnopqrstuvwxyzABCDEFGHIJK123456789* link for a non-public folder file (rather than the https://www.dropbox.com/home/*folders*?preview=*file.ext* link). This is actually the link for the anchor tag for the file in the file list on the web, but clicking on most opens the files in preview mode (still not sure why ones named "1password.html" are exempt). To open the non-preview link you can Shift-Right-Click, to get the browser right click menu instead of the Dropbox one, and just chose "Open in new tab/window".
Using the 1password.html file as a guide it looks like you can load separate scripts/files using ajax. They embed all CSS and images in the HTML file (images using base64).
Edit: It looks like Dropbox provides special functionality to 1password. Other non-public pages can not load scripts/data from the same folder tree (error 403). Even renaming the 1password.agilekeychain folder and breaks its functionality.
In the VS2010 IDE when a breakpoint (or an error) is hit, it opens a read-only [dynamic] version of the external JavaScript file I referenced. My workflow would be vastly improved if I could immediately edit this file, and refresh the browser. That is as opposed to digging up the original JS file opening it, finding the correct line and editing there.
I only know that this is possible because I was able to do this on my old work computer configuration, but for the life of me I can't duplicate it at home.
Has anyone made this work? Perhaps an extension? or maybe it has to with the way the files are referenced, or my basehref tag, or url rewriting.
This happens when the base href specifies a domain other than localhost. My issue was that to enable a local environment for Facebook JS, I need my domain in the url. So I set up my host file to remap localhost.mydomain.com to localhost.
When the Visual Studio IDE encounters a file reference which is something other than localhost, it does not attempt to grab the local file since it assumes (correctly in most cases) that it is being served from another site. In these cases it loads a file as [dynamic] and readonly.
Here is the test case:
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<base href="http://localhost.mydomain.com/virtual-directory/" />
<script type="text/javascript" src="test.js"></script>
</head>
<body>
</html>
Any breakpoint within test.js will result in opening a readonly dynamic file.
how are you referencing your files? whenever a script block is written inside the html or is dynamically inserted the debugger will open the instance of the page where the code stops. If you reference the script using tags vs should open the original script file (at least that's what it does on my machine). could you upload an example of your current structure?
I tried different methods to open and show a file on client without to send the file to a server.
Opening: I tried to access the file with javascript from a <input type=file>, but the security restriction seems to not allow that.
I tried also <iframe src=file://local.path> with the same problem.
Last i tried with new ActiveXObject('Scripting.FileSystemObject');, but I get always an error that automationserver could not create the Object.
For saving I tried to use execCommand('SaveAs',true) from TextRange and DocumentFragment. From DocumentFragment I'm able to save a file but it contains only <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">. From TextRange is no save dialog shown.
What could I do?
From a web site, you cannot do any of this unless you use a signed script
From local file system, IE can use the filesystem object from an HTA
Sorry,
You can not access the local file system through a browser without having the user install a plug-in/activex object.
It may be that you should try another cross-platform delivery method, such as Adobe Air.