简体   繁体   中英

HTML file that opens a link in a browser

是否有一种方法可以单击HTML文件或其他格式,从而打开默认浏览器并导航到指定的http://网页,而不是本地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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM