How can I link to another URL when my web page opens without clicking on "link"?
I'm just learning html and understand how to link using the anchor and href.
Example:

<html>
<body>

<p>
<a href="http://msm/com">
Click Here </a> 
</p>

</body>
</html>

How can I get my webpage to open the link without having to have the "Click Here" present?

Recommended Answers

All 2 Replies

You can either use a refresh meta-tag or you can set window.location in javascript.

Here is the javascript solution:

<html>
<head>
   <script type="text/javascript">window.location="http://msm.com";</script>
</head>
</html>

Here is the REFRESH solution:

<html>
<head> 
  <META http-equiv="refresh" content="1;URL=http://msm.com">
</head>
<body>
    REDIRECTING YOU.... 
</body>
</html>

Thanks very much. Both solutions work great.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.