I want a list of hyperlinks on a basic html page, which point to files on our corporate intranet.
When a user clicks the link, I want the file to open.
They are excel spreadsheets, and this is an intranet environment, so I can count on everyone having Excel installed.
I've tried two things:
The obvious and simple thing:
Click me!
A vbscript option that I found in a Google search:
<HTML>
<HEAD>
<SCRIPT LANGUAGE=VBScript>
Dim objExcel
Sub Btn1_onclick()
call OpenWorkbook("\\server\directory\file.xlsx")
End Sub
Sub OpenWorkbook(strLocation)
Set objExcel = CreateObject("Excel.Application")
objExcel.Visible = true
objExcel.Workbooks.Open strLocation
objExcel.UserControl = true
End Sub
</SCRIPT>
<TITLE>Launch Excel</Title>
</HEAD>
<BODY>
<INPUT TYPE=BUTTON NAME=Btn1 VALUE="Open Excel File">
</BODY>
</HTML>
I know this is a very basic question, but I would appreciate any help I can get.
Edit: Any suggestions that work in both IE and Firefox?
Try formatting the link like this (looks hellish, but it works in Firefox 3 under Vista for me) :
file.ext
<a href="file://server/directory/file.xlsx" target="_blank"> if I remember correctly.
If your web server is IIS, you need to make sure that the new Office 2007 (I see the xlsx suffix) mime types are added to the list of mime types in IIS, otherwise it will refuse to serve the unknown file type.
Here's one link to tell you how:
Configuring IIS 6 for Office 2007
You may need an extra "/"
Click me!
If the file share is not open to everybody you will need to serve it up in the background from the file system via the web server.
You can use something like this "ASP.Net Serve File For Download" example (archived copy of 2).
A simple link to the file is the obvious solution here. You just have to make shure that the link is valid and that it really points to a file ...
You're going to have to rely on each individual's machine having the correct file associations. If you try and open the application from JavaScript/VBScript in a web page, the spawned application is either going to itself be sandboxed (meaning decreased permissions) or there are going to be lots of security prompts.
My suggestion is to look to SharePoint server for this one. This is something that we know they do and you can edit in place, but the question becomes how they manage to pull that off. My guess is direct integration with Office. Either way, this isn't something that the Internet is designed to do, because I'm assuming you want them to edit the original document and not simply create their own copy (which is what the default behavior of file:// would be.
So depending on you options, it might be possible to create a client side application that gets installed on all your client machines and then responds to a particular file handler that says go open this application on the file server. Then it wouldn't really matter who was doing it since all browsers would simply hand off the request to you. You would have to create your own handler like fileserver://.
This works in Firefox 96 in macOS 12, and should work in other browsers and in Windows too:
open file
Your first idea used to be the way but I've also noticed issues doing this using Firefox, try a straight http:// to the file - href='http://server/directory/file.xlsx'
Related
I'm taking a programming class on Lynda.com and I just finished creating this HTML web page, but it's not opening on a web browser. Can someone help me figure out what I did wrong? Thanks! :)
Here's what I did:
Picture
I took a look at your code and it not only looks correct, it displays for me on Chrome, Firefox, Opera, and MS Edge.
I'm thinking that it may be the manner in which you are trying to access the file to display.
Follow these two solutions and see if one of them works for you:
Solution 1) Find where on your hard drive you are saving your "body.html" file. When you find the file, click on it and it should automatically open the file in whatever your default browser is for you.
Solution 2) If you are trying to manually type in the directory address for your "body.html" file inside the web address box of your browser, make sure you are writing the address correctly. Remember, the address is coming from your hard drive and not the internet itself. A format would look something like this:
C:/Website-Projects/body.html
or try:
C://Website-Projects/body.html (***the only difference is the 2 back slashes instead of one).
in the example above, "C" stands for the designation of my hard drive, "Website-Projects" is the name of the folder on my "C drive" that my target file is in, and "body.html" is the target file I'm trying to open within the "Website-Projects" folder.
Give those two solutions a spin and see if that helps.
so, i've ben hunting for the answer, and seems like i can't get this to work, i wanted to make so that, i have a browser page already made in html, and when i click a link in there, it opens a chosen folder on the computer, but i don't want it to open on just this computer's path, I wanted to open a folder that is inside the main folder, so that anyone that has the same files as I do, can open it, i tried < a href="File_path">, tried putting < a href="file:///(file path)">, tried like i have in excel ../../'file path', and can't see where is the problem, anyone can help?
Here you need to use a "file" protocol to link a file in the HTML like,
Link
The browser may or may not open the file due to the security setting. You can click the right button and choose "copy link address" and then paste it into the browser.
There are security implications of showing a local file/folder from an website. It may work when the page is held locally but when on a server it will be failing. However definitely not any chosen folder anywhere in your PC.
If you require to achieve such you need custom implementation using a programming language like ASP .NET like shown in this example.
https://stackoverflow.com/a/6047826/684030
You haven't mention much details on what web server you are using. But if it's IIS (Windows) you may consider allowing directory browsing which may allow to show a sub directory under your website.
I am currently building an asp intranet site.
There are various helpful links that I need to include and some of them happen to be .xls files that are located on a local network within the company.
I link these documents just like I would any word docs (which work fine by the way).
<span>Schedule</span>
The link above works if I simply copy and paste the raw address into my browser (a pop-up window comes up asking me to open the file in Excel). But when I make this a link on the intranet site and try to click on it, nothing happens. I can see the link when I hover over it on the status bar but that's it. It is non-clickable. Anyone have any idea what is causing this and how to fix it?
I should mention that two of these .xls files are password-protected but one of them is simply a read-only file which can be opened by anyone.
I am 100% sure this has nothing to do with css styling because the same thing happens in the current (old) intranet site made by someone else and I use these links on different menu bars as well.
I think you use wrong syntax for shared files, try this:
file:///P:\-Projects-\SCHEDULE.xls
Backslashes are still valid for the path part. Moreover, I'm not sure whether Sharepoint may recognize correctly path to most likely network drive P:.
For me such link to local share works:
file:///\\fs-1\Install\Windows\Servers\DB\MSSQL\SQL2005\en_sql_server_2005_service_pack_4_x64.exe
The solution to this problem is to add the site to the "Trusted Sites" list.
Opening intranet files without the user knowing is considered a secruity threat.
In IE go to Internet Options -> Security -> Trusted Sites then add the site.
http://answers.microsoft.com/en-us/ie/forum/ie9-windows_7/after-latest-update-ie-wont-open-network-file/172e4ac3-1c1f-4948-8a3f-c8c344eae06d
the title basically says it, i have a from with a treeview and a webbrowser control and three buttons. i want the back button to load the previous viewed html file from myresources and the same but opposite for forward?... also how can i and where can i link my external css to my program like my.resources so when i export the program for installing on another machine it still works? and one more thing... how can i intergrate/embed the webbrowser control into my program because as i believe it uses internet explorer and if someone installs my program onto their computer and they have un-installed ie and use firefox it won't work? thank you guys very much, i know it's a lot of questions but you guys are awesome!. thanks
It would be easy for you if you read this web pages from the resource file and then save them to a disk.
In this way you can simply pass the physical path to the Navigate method and similarly you can use GoBack and GoForward and Print methods.
But if you don't want them to save them, you still can read the web pages from the resource file and then use DocumentText property to display the webpage.
Using this method you won't be able to navigate back or forward.
My scenario is this:
I have two network shares (on the same network) that I would like to construct them as a A HREF network share. I tried to make it work with all the solutions given here but couldn't succeeed. These A HREF links are generated on the fly thru a application and sent as a HTML Outlook e-mail. I wanted the link to look like this in the Outlook HTML e-mail.
\\remote_machine_name\sharename1\Windows\notepad.exe \\remote_machine_name\sharename2\SCANDISK.acc
So, all I need is make notepad.exe open on the remote machine along with SCANDISK.acc open on the same remote machine and as a input to notepad.exe. Please note that the remote machines are same both for notepad.exe and for the .acc file but the share names are different.
Btw, I'm also thinking of another possibility of generating javascript code on the fly from the application and take the .acc file as an input and in the javascript method, open notepad.exe and input .acc file to it. Will this work?
As a side note, whenever I click on the .acc file link in the HTML Outlook e-mail, I'm getting a warning from Outlook with a dialog that shows (Open, Save and Cancel).
Please help.
You'll want to do something like this:
file://///servername/sharename/path/to/file/file.ext
There are five slashes after file: and they mean: /// for the file protocol and // for the path to the server. A normal windows path would be like this:
\\servername\sharename\path\to\file\file.ext
All you need to do is reverse the slashes and append it to file:///
Weird answer that works for on new Edge
Im new to HTML and coding in general but i got this to work using this code
make sure you add (<)p(>)(<)a(>) but without () and before href
cant show it all together otherwise it will not show the code on here
href="\server\folder\location" target="_blank" rel="noreferrer noopener">test
The code is a website link opener that will open said folder in a new browser tab.
"test" being the visual hyperlink name that users will click on. This should work on cloud drives in your intranet as well local drives.