سؤال

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.

هل كانت مفيدة؟

المحلول

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

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

نصائح أخرى

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!

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top