Jason Cameron
Jason Cameron

Reputation: 51

redirect with html or javascript

I am working on a page where I need to redirect people from my home page to my cover page. While still being able to go back to the home page afterwards (part of a school project) I have the link to go back to my index.html, but not sure what is best practice to redirect?

I am using the code:

<head>
<meta charset="utf-8">
<meta http-equiv="refresh" content="1; url=http://www.cameronwebsites.com/wps/cover.html/" />
<title>Brillings Fittings Inc - Home</title>
<link href="css/styles.css" rel="stylesheet" type="text/css">
        <script type="text/javascript">
            window.location.href = "http://www.cameronwebsites.com/wps/cover.html"
        </script>
</head> 

Yet it keeps redirecting me to examples.com not the actual URL? I am very confused.

Upvotes: 1

Views: 607

Answers (2)

Rodney Salcedo
Rodney Salcedo

Reputation: 1254

You can redirect after X seconds, so you could show a message before go to another page

<head>
    <meta charset="utf-8">
    <title>Brillings Fittings Inc - Home</title>
    <link href="css/styles.css" rel="stylesheet" type="text/css">
    <script type="text/javascript">
        function redir(){
            window.location.href = "http://www.cameronwebsites.com/wps/cover.html"
        }
        setTimeout ("redir()", 1000); //1 second
    </script>
</head>

Upvotes: 0

gwar9
gwar9

Reputation: 1082

If that is your actual code you are missing quotes

url should be url="http://www.cameronwebsites.com/wps/cover.html/"

The meta refresh tag is the simplest way to redirect so I would say you are good to go.

Upvotes: 1

Related Questions