HTML file that opens a link in a browser - html

Is there a way for an HTML file or other format that when clicked, will open the default browser and navigate to a specified http:// web page, NOT a local file:// ?

<script>
location.href = 'www.someUrl.com'
</script>
Just create an html file that contains something like the above. When you click it you will be redirected.

At least for an HTML file, no. When you click on an HTML file, your computer will open it in your default web browser, and the URL at the top will will be a file:// as that's the location of your file. You can, however, include some JavaScript to redirect people.
<script>window.location = "https://www.google.com";</script>
That way people will open the local file, but they will be automatically redirected to Google.

Yes, a shortcut.
Create shotcut and type your browser application url and add link.
Example like this:
"C:\Program Files\Firefox\firefox.exe" "http://www.google.com"

Do you mean if there is a way to set your HTML files to a default web browser, so that when you double-click them, they'll open up in....lets say for example (chrome.exe, firefox, opera, etc etc...)? If so, I recommend you right click the HTML file and navigate to "open with", and choose the web browsing program you want to use.
If you really want to take the easy route. Download notepand++ text editor(notepad-plus-plus.org).
Here's a picture of how to run HTML file in notepad++ in the browser:
http://i.stack.imgur.com/Yuynt.png

Related

how can i directly open browser to view html file from vs code?

I write HTML and CSS code in VS Code and for previewing it I need to open file explorer then files then double click them to open them in my default browser.
it takes too much time. is there any proper way for this?
I have tried one live extension called live server but the problem with it is we have to click the 'go live' button any time I want to refresh the code.
If the live server extension is the one by Ritwick Dey..
.. then then after clicking Go Live, it will open your page in the default browser and reload it automatically, every time you save your work.
in some cases, it is helpful to save the folder containing your HTML to a Workspace, in VS Code, especially if you are writing an app using the MVC modal and the HTML and CSS are in subfolders.
You can install an extension called open in browser.
After installation complete restart vscode and go to settings Ctrl + ,. Search for Open-in-browser setting and set your default browser as you can see below:
Then whenever you edit a html file, you can use shortcut Alt + B to open this file in browser.

creating a link to a local file on a locally-run web page (Chrome), while "Local File Links" extenstion is enabled

I want to use the html href attribute as a hyperlink to present a local html file, located on my hard rive.I have the following code, and I'm using the Chrome browser:
List: Specified
The "Local File Links" extension is enabled.
I've also tried:
(a) href="file:///F:......\nameOfLocalFile.html">Specified
(b) List: Specified
It doesn't work and the files are not opened.
Is there a new way today (11/2019) in html to access other files on my hard drive in Chrome (and in other browsers, possibly). Is there a certain extension in Chrome I am missing or a certain keyword in html for achieving this?
I am running Windows 10 and Using Chrome as default browser.
You have done a simple mistake.
Try to change your \ to /.
Click
Your problem will be sorted out

How to make PDF from GitHub open in new tab?

I have a pdf file in a GitHub repo and an anchor tag that points to it (<a href="https://github..../file.pdf>link</a>) and when I click it, i download the file automatically.
How to make it open the PDF in a new tab, before downloading it (to the file system, just downloading it within the browser)?
I've tried adding target="_tab" and target="_blank" to the anchor, but all got me the same results?
Is it achieable using just HTML, or I need to use an external JavaScript library?
You shouldn't need to add target="..." whatsoever. I guess you're pointing to the wrong URL. GitHub provides access to the raw file through this URL pattern:
//github.com/<account>/<repo>/raw/<branch>/path/to/file.pdf
Note the raw part in the URL. Check if you got your URL right. A functional example:
Test PDF
You can test it clicking this link. A dialog will open asking you to specify where to download it.

How to force a Download File prompt instead of displaying it in-browser with HTML?

Download
If I click Download button, this target blank is opening a new window.
But I need it to prompt a dialog for saving this file. How can I achieve this?
This is something that you cannot absolutely control with HTML itself.
If the user is having a browser with PDF reading capabilities (or a plugin) and the corresponding settings to open PDF files in-browser, the PDF will open like that.
The PDF opens in a new tab simple because of your target="_blank", which has nothing to do with a download prompt.
If you are using HTML5 you can use the download attribute:
Download
If you have a back-end service which you can control or you feel like fiddling with your Web Server, you can always look for setting the right Content-Disposition. See this SO question for some nice discussion on Content-Disposition.

Files With Extension "doc" Must Show in Browser Instead of Download

I have uploaded a doc file on my server and when i open this file by it's url then it's automatically downloaded but i want that this should open in a browser instead of downloading,please help me to resolve this issue.
If you want open your document inside Browser, you can try the following settings:
The setting that controls this behavior is located in Windows Explorer (not Internet Explorer) on the user's machine.
Open “Windows Explorer”.
Select Tools -> Folder Options... from the menu.
Go to the “File Types” tab.
In the “Registered file types list”, select the file you want to change the setting for (e.g. DOC).
Click the “Advanced” button to open the Edit File Type dialog.
There is a checkbox, Browse in same window, where you can specify whether the selected file type should be opened within the browser or launched in its host application when clicked on a web page.
For more information, please refer to: http://support.microsoft.com/?scid=kb;en-us;162059
Have you tried to use the page view web part and link to the document?
Also, does it have to be a word document? Could you try a different approach for the content, like using one of the page layouts or the content editor web part?