I'm learning javascript. The portion I'm learning right now is how to write a short page that alerts the user that their javascript is not enabled. Then , when they enable it, javascript code written into this same page auto-redirects the user to a another page that requires javascript.


I run firefox with the noscript add on. I'm learning to write code that first asks the user to enable javascript. When they do, redirect to mypage.html

The code below renders "Please enable javascript" when javascript is turned off - as it should. The autoredirect happens when javascript is turned on - as it should.

The problem is the absolute url of the "mypage.html" file in the code is also rendered as a blue link when javascript is off. I don't want that rendering when off.

I do use html comment tags as you can see in the code below. They don't stop the rendering of the link. Can anyone help?


Here is the code:

<!DOCTYPE html>
<xhtml>
<head>
<style type="text/css">
body {margin: 20em;}
</style>
<title>No Javascript Page</title>
</head>

<body>
<noscript>Please enable javascript</noscript>

<script type="text/javascript">
<!--
location.replace("mypage.html");
//-->
</script>
</body>
</xhtml>