0

I am attempting to add a simple condition into an html file as a test. I am trying to create a simple file that tells the user wether his javascript is enabled or not.

    <Noscript>
        <A>Javascript is disabled</a>
    </noscript>

    <Script type="text/javascript" language="javascript">
        <A>Javascript is enabled</a>
    </script>

When I run the script, I get a syntax error. If I change the type to javascript, the error goes away but the code does not work. Why do I get this error and can anyone suggest a good javascript editing tool because I'm using notepad to learn.

3
  • 3
    Friend, you are supposed to insert javascript code inside the script block and not HTML. Commented Feb 14, 2013 at 20:00
  • A script wrapper expects JavaScript, not HTML. Commented Feb 14, 2013 at 20:01
  • Inside the script tag: document.write('<a>Javascript is enabled</a>'); Commented Feb 14, 2013 at 20:02

2 Answers 2

1

To print in javascript you use document.write('...');

Here is a good site where you can learn Javascript -> http://www.codecademy.com/tracks/javascript

Sign up to request clarification or add additional context in comments.

Comments

0

The noscript tag will do the trick for users without JavaScript enabled. For those that have it enabled use JavaScript to display the enabled text.

<noscript>
JavaScript is not available
</noscript>

<p id="enabled">
</p>

<script>
var enabledTag = document.getElementById("enabled").innerHTML = "Javascript is enabled";
enabledTag.appendChild(document.createTextNode("Javascript is enabled"));
</script>

Try it on jsFiddle!

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.