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

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.

Related

How to show File Saveas Dialog in Blazor Server App

I am new to Blazor and trying to show File Saveas Dialog as shown in following link on a button click.
Save as Image
The requirement is - upon clicking the Saveas button above Saveas dialog should be popped up where user can choose the destination of file and file name.
I have tried "enabling the setting to check the save location in the download settings of the browser" and it works. But we do not want to depend on the Browser settings.
Please add your thoughts on below..
Instead of depending on the browser settings is there any other way to show Saveas dialog?
Are there any open source Nuget packages available to help on this?
NOTE: I am using .NET 6.0 for building my application
Thanks in advance,
Bhargavi Gowri.
I also wanted to bring up a window to save a file in which the user could select a folder. Before that, the system automatically saved to the Downloads folder.
As I understood, there was no such possibility before, but now it is possible thanks to this api: https://caniuse.com/native-filesystem-api.
I found this solution in the answer to this question: https://stackoverflow.com/a/70001920/16740180.
It's worth noting that I use Blazor WebAssembly and not a Blazor Server. And I do not know if it will work for you.
Unfortunately, this doesn't work for mobile devices right now, but it works fine for windows. I hope this helps someone.
This isn't a Blazor thing. In web browsers, files are downloaded from links using <a> tag in HTML using the download attribute. Just create a link to your file:
<a href="path_to_file" download>Save</a>
Save
The path must be on the same server, but blob and data links will work as well.
If you do not suggest a name, the browser will use the original filename (possibly changed to remove symbols the OS doesn't allow in file paths).
https://caniuse.com/download
If you want your link to look like a button, then that's a different issue, and you can google or ask that.

Cannot connect to localhost on Chrome when using VSCode

Just written a HTML document using VSCode. When i run via Chrome it opens a window on localhost:8080, but says that the site cannot be reached. 'Refused to connect'
Can anyone tell me where I'm going wrong?
Usually use Notepad++ which i realise is so much more straightforward than VSCode.
Thanks.
You can just click on the file and it will run automatically.
You don't need localhost to view an HTML page, just find the HTML on your desktop or documents or where ever you created it, right click on the file and open it with a browser of your choice
You can then edit the file in VSCode or Notepad++ or any text editor of your liking, then go back to the browser and reload the page to see the changes to your file
You enter your project. And you can run as writing 'ng serve'. VSCode will show your localhost and you should press it to run the project.
[Javascript],[VisualStudioCode],[AngularJS]

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 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?