|
|
|
|
|
|
| |
This script works in any browser that supports javascript. No PHP or special scripting is involved.
The only scripting languages used in this script are Javascript and HTML. The script is a fairly short script, but it will do the job.
It will be easier to understand this script if you have a simple knowledge of HTML and javascript. If you don't you can still just copy and paste into your website.
This script is free to all, and it can be edited, reposted, or redistributed.
By taking/using this script, you understand that I am not responsible for any problems that may occur.
Use the example below to do this in your website. First, make a file with a file extension that supports HTML and Javascript (such as .html OR .php). Remember to include the "onLoad" portion of the body tag.
|
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title>Soeren Walls - How to Check if Javascript is Enabled</title>
<script type="text/javascript">
function checkForJavascript() {
/* use this code to only display a message when javascript is disabled */
document.getElementById('divJavascriptDisabled').style.display = "none";
/* use this code to show different messages based on whether Javascript is enabled or not */
document.getElementById('divJavascriptChange').innerHTML = "Javascript is enabled.";
}
</script>
</head>
<!--
**** REMEMBER to include the "onLoad" portion of the body tag. It is vital to the code.
-->
<body onLoad="checkForJavascript();" style="font-family: Trebuchet MS, Lucida Grande, Verdana, Arial, Sans-Serif; font-size: 12px;">
<p>
Script written by Soeren Walls.<br />
You may remove this message if you would like to. This script is free to all and can be edited, reposted, or redistributed.<br />
By taking/using this script, you understand that I am not responsible for any problems that may occur.<br />
This script works in any browser that supports javascript. No PHP or special scripting is involved.<br />
__________________________________________________________________________________________________
</p>
<p>
If javascript is disabled, you will see a message below. If it's enabled, no message will appear.
</p>
<div align="left" id="divJavascriptDisabled" style="width: 300px; display: block; background-color: #005263; border: 1px dashed #000; padding: 3px; color: #FFFFFF; text-align: center;">
Javascript is disabled. Please enable javscript.
</div>
<p>
__________________________________________________________________________________________________
<br />
Or, if you would like to display different text depending on whether Javascript is enabled or disabled, then use the following script.
</p>
<div align="left" id="divJavascriptChange" style="width: 300px; display: block; background-color: #005263; border: 1px dashed #000; padding: 3px; color: #FFFFFF; text-align: center;">
Javascript is disabled. Please enable javscript.
</div>
</body>
</html> | | |
|
| How to keep your tables width stable even if you have long strings inside. Categories : CSS, Web Browsers, HTML, Beginner Guides | | | Show or Hide your Content using Javascript Categories : Java Script, HTML, CSS, Beginner Guides | | | How to create <SELECT> menues that change on the fly according to other <SELECT> menues on the page? Categories : Java Script, HTML | | | Cool tool tip Categories : Java Script, HTML, Web Design | | | Higly Customizable Javascript Calendar Script Categories : Java Script, Calendar, Date Time, HTML, CSS | | | showing Help (assistance) to the user while filling html forms. Categories : HTML, Java Script, Form Processing | | | Conditional Check - a script that allows a user to submit a form only if the user check a checkbox. Categories : HTML, Java Script, Form Processing, Beginner Guides | | | Prevent Right Mouse steal your graphics Categories : HTML, Java Script, Security | | | Bookmarklets are simple tools that extend the surf and
search capabilities of Netscape and Explorer web browsers. Categories : Java Script, HTML, General | | | Unobtrusive javascript for maintaining scrollable layer state Categories : DHTML, Java Script, HTML | | | AutoComplete in HTML forms Categories : DHTML, HTML, Web Browsers | | | Enchancing dd/mm/yyyy forms with unobtrusive javascript Categories : Java Script, HTML, User Interface, Date Time | | | Mordern Peroidic Table - Science Categories : Java Script, HTML, Charts and Graphs | | | Javascript linked dropdowns Categories : Java Script, HTML, Classes and Objects | | | Javascript animated menu items Categories : DHTML, CSS, Java Script, HTML | |
|
|