Click here to Skip to main content
15,861,168 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.

Thanks,
Santhosh
Posted
Comments
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.
--SA
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.


HTML
<!DOCTYPE html>
<html>
<head>
<script>
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;
            hdc.fillRect(x,y,1,1);
        }
    }

	var base64ImgStr = 
		   "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAABzklEQVQ4T1WTu1I"
 +"DMRRDr3dtr19UUJEqNFClSZMCZmBgQvL/H2QkeZdAccd5SXuk6zgz6957S0uyJUWLONOCMy4WQ7QQvQUfzAcM"
 +"fjdNk83zbM45mzAOH/acIMIsnGX5HRksQQYBBhTOHjPNMHJ49mSu1dZzHgYpZ4n5Ov5SBNDASBQQz4OCQwp3f"
 +"/8gg5wyDIhPElKQhpEYZRB4moDgbwy3e9z1XEiQLYOAFIkGcYvDPjCI49GHBwGjiAAx3P5p30suIABFKaIgjQ"
 +"hglCgmBWOsRcqAwwgvL88ySJhSbhSZZW6R/hmsXagDbONwOKADim8GjKI47EV9cEhAknUbIoDJ8XjstSJCrlZ"
 +"qNtIokvoY3dCEM2KgC5XJTYDgdDr1UqtVEdyGfRSKUbA2xBjohQQBRn4r8u3ttZfCp9NkUPDM6EOGijNKZrGR"
 +"JLiRupVYqXt//+itlVUMExhJyBNivlcnMOQd0SVbN8JNuK+vT3TQIKrWGg1ghveKRBOSyYC9cNYLhi5mULjz+"
 +"SwDiWFSZTKmbQYbFSOul46bCTT4vlz6nQR4KsSDAq9pCprSeK796CFj3dwOo7jL9drxh5Lwr5hmd4xGEgr5vY"
 + "xvhCz2B4Y9LU8XKxijAAAAAElFTkSuQmCC";

    document.body.style.backgroundImage = "url(" + base64ImgStr + ")";
    document.body.style.textAlign = 'center';

    var myHeading = newEl('span');

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

</script>
<style>
</style>
</head>
<body>
    <noscript>This page depends on JavaScript. Enable Javascript then reload this page</noscript>
</body>
</html>
 
Share this answer
 
v2
Comments
Sergey Alexandrovich Kryukov 10-Nov-12 23:27pm    
Good points, a 5.
--SA
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