SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Enthusiast
    Join Date
    Jan 2006
    Posts
    92
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Javascript Check

    I am currently creating a site that is going to use lots of javascript, but if a users browser does not have javascript enabled then i want them to access stuff via php. Here is what I have in my pages...
    Code:
    	<body onload="javascript:JavaScriptCheck('JavaScriptHidden')">
    		<input id="JavaScriptHidden" type="hidden" value="no" />
    Here is my javascript...
    Code:
    function JavaScriptCheck(HiddenField) {
    	var Hidden = document.getElementById(HiddenField);
    	Hidden.value = "yes";
    }
    What I want this to do is when the page loads to make the value of the hidden field 'yes' through the use of javascript. If the field changes from no to yes then I know javascript is enabled. Can anyone tell what I am doing wrong so that this procedure will work?

    Thanks in advance for your help.

  2. #2
    Programming Team silver trophybronze trophy
    Mittineague's Avatar
    Join Date
    Jul 2005
    Location
    West Springfield, Massachusetts
    Posts
    17,154
    Mentioned
    190 Post(s)
    Tagged
    2 Thread(s)

    javascript to detect javascript

    Might it not be easier to simply use noscript tags? You don't need any hidden inputs to test for whether or not javascript is enabled, if it is the javascript will work, if not, it won't.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •