Click here to Skip to main content
14,884,032 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hi friends...

In my application I created mostly 90% Javascript used and User Disable Javascript in browser then How to handle this situation in our application without change alignment...

Please If any one get idea Let me know...
Thanks in Advance.

enhzflep 10-Nov-12 20:57pm
What do you mean 'without change alignment'? Does the layout of your page depend on Javascript? In any case, if the user has disabled Javascript, there's nothing you can do except tell them that the page wont work with it disabled. That, and not rely upon it for layout - not that it really matters if the page looks a bit funny, if it also doesn't work. Just include a text that says Javascript Required, then when javascript loads, remove this message. No javascript, no removal.
Sergey Alexandrovich Kryukov 10-Nov-12 22:09pm
Agree. And it's good for a short explanation. Again, I would up-vote it, especially if elaborate it just a bit and posted as solution.
enhzflep 10-Nov-12 22:48pm
Thanks SA,
having a closer look reminded me of the noscript tag. A much better solution than manually removing a 'No JS enabled' type message.

1 solution

Further to my comment above, you may wish to investigate the <noscript> tag. This tag's contents will only be rendered if the user's browser doesn't have a JavaScript capability - either because it lacks the functionality, or because the user has turned it off.

The ability to turn-off JavaScript isn't going away any time soon, as for a number of reasons, some people will only ever use the net with it disabled.

The correct approach to take in this instance is to present a message informing the user of the site's dependence on it, along with a suggestion to enable it.

Here's a sample page that presents differently with JS on/off.
Note, that I didn't have to remove the <noscript> tag from the page.

<!DOCTYPE html>
function byId(e){return document.getElementById(e);}
function newEl(tag){return document.createElement(tag);}
function newTxt(txt){return document.createTextNode(txt);}

window.addEventListener('load', mInit, false);

function mInit()
    var canvas = newEl('canvas');
    canvas.width = canvas.height = 256;
    var hdc = canvas.getContext('2d');
    var x, y, curCol;

    for (y=0; y<canvas.height; y++)
        for (x=0; x<canvas.width; x++)
            curCol = 'rgb(' + (x^y) + ',0,0);';
            hdc.fillStyle = curCol;

	var base64ImgStr = 
 + "xvhCz2B4Y9LU8XKxijAAAAAElFTkSuQmCC"; = "url(" + base64ImgStr + ")"; = 'center';

    var myHeading = newEl('span');

    myHeading.appendChild( newTxt('Welcome to my JavaScript-only page') ); = 'rgba(255,255,255,0.6)'; = '2em';
    document.body.appendChild( newEl('br') ); = '0 10px 20px black'; = '10px'; = 'blue';

    <noscript>This page depends on JavaScript. Enable Javascript then reload this page</noscript>
Sergey Alexandrovich Kryukov 10-Nov-12 23:27pm
Good points, a 5.
enhzflep 10-Nov-12 23:44pm
Thank-you. :)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900