Save a .html file which loads a URL when you open it - html

I'm simply trying to open google.com via a .html file.
When I open this .html file it does not load Google.
<!DOCTYPE html>
<a href="http://www.google.com">

This should do the trick:
<!DOCTYPE html>
<html>
<head>
<title>Google</title>
<meta http-equiv="refresh" content="0; url=http://www.google.com" />
</head>
</html>

Anchor tag acts as a hyperlink. You'll have to click on it manually or write a script that would do it for you.
If you want to open google directly without the user's action, you can use a meta refresh.
<meta http-equiv="refresh" content="4;url=https://google.com" />
here, 4 would represent the amount of time you need before refreshing in seconds.

Related

Redirecting my websites index page to another page in my website?

I don't know how to redirect my index page to another page like when you go to www.example.com it redirects to www.example.com/home. I use GitHub pages for this how can I do this.
<meta charset="utf-8">
<title>Redirecting to https://example.com/</title>
<meta http-equiv="refresh" content="0; URL=https://www.example.com/home">
<link rel="canonical" href="https://www.example.com/home">
Try putting this in your <head></head> in your index.html file.

Image not loading in my html page when using Live Server extension in VS Code

I have started studying web development and decided to use VS Code. It is currently running on a Linux Mint dist (19.03). Decided to add some extensions, including Live Server so I don't need to constantly hit F5 to see the changes. Problem is: I inserted an image on my html page and if I open the page through Live Server, the picture just doesn't show up, but if I go to the HTML file and open it, it shows perfectly. Could someone help me with this issue? Thank you! I am leaving the code here so you can have a look:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>DOM</title>
</head>
<script src="dom.js"></script>
<body>
<img src="/../HTML/me.jpg" />
</body>
</html>
/../ in the img src tag does not look correct.

Page redirection not working unless I add .html to the URL

I had a client that gave a URL in a press kit before the website was done. He gave a page when I was making the website a one page site. So I took the URL he made and coded it as a redirect to scroll to that part of the site.
Now that I have it online, it isn't working properly.
fuzzripper.com/bio gives me an internal server error
fuzzripper.com/bio.html works just fine
I would like it to work even if the user doesn't type .html
Here is my redirect code
<!DOCTYPE HTML>
<html lang="en-US">
<head>
<meta charset="UTF-8">
<meta http-equiv="refresh" content="1; url=http://www.fuzzripper.com/#about">
<script type="text/javascript">
window.location.href = "http://www.fuzzripper.com/#about"
</script>
<title>Page Redirection</title>
</head>
<body>
<!-- Note: don't tell people to `click` the link, just tell them that it is a link. -->
If you are not redirected automatically, follow this <a href='http://www.fuzzripper.com/#about'>link</a>.
</body>
</html>
A quick fix for static sites is to
Create a /bio folder
Move bio.html in bio folder
Rename bio.html to index.html
This should make the bio#about link work just fine.

Why is this meta content redirect not working

The default document for the IIS .Net project is a Default.htm file. The following code reflects the contents of the Default.htm file.
When it runs, it does not redirect to the Project1 folder, but looks for the Login.aspx in the current directory instead (example: www.website.com/Login.aspx when it should be www.website.com/Project1/Login.aspx). I assumed my url tag was incorrect, however it is without flaw.
<html>
<head>
<meta HTTP-EQUIV="REFRESH" content="0; url=Project1/Login.aspx">
<title>Welcome</title>
</head>
<body>
<p>Loading ...</p>
<p>Please click here to login</p>
</body>
</html>
Why does it not look in the Project1 folder for the Login.aspx?
You need to change to this (add slash at the beginning of url):
<meta HTTP-EQUIV="REFRESH" content="0; url=/Project1/Login.aspx">

HTML link does not open

I have a test HTML page with a link:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title></title>
</head>
<body>
Log in with TouchLogin
</body>
</html>
When clicked, the link does nothing. If I add the target = "_blank" attribute, the link opens a new tab, but does not load the URL specified. If I Ctrl-Click it, the link opens fine. What is going on?
Thanks in advance.
Glad you figured it out!
Omitting the http:// will always attempt to open the resource local to where the code originates.
For example, if you're working offline...
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title></title>
</head>
<body>
Log in with TouchLogin
</body>
</html>
Will open something like c://user/parent/localhost:8080
And working online will open something like http://parentsite.com/localhost8080
SO, leave out the http:// when linking to pages on your site but include when linking externally. :)
Figured it out upon using a different URL in the href(google.com). It did not work without "http://", so I added "http://" to the localhost link and it worked.