用户在浏览器中禁用Javascript

用户在浏览器中禁用Javascript

问题描述:

朋友们...

在我的应用程序中,我创建了90%使用过的Javascript,并在浏览器中禁用了用户Javascript,然后如何在不更改对齐的情况下在我们的应用程序中处理这种情况...

如果有人有主意,请告诉我...
在此先感谢.

谢谢,
Santhosh

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

在我上面的评论中,您可能希望调查< noscript>标签.仅当用户的浏览器不具备JavaScript功能时(因为缺少此功能或由于用户已将其关闭),才会呈现此标签的内容.

关闭JavaScript的功能不会很快消失,由于多种原因,有些人只会在禁用网络的情况下使用它.

在这种情况下采取的正确方法是呈现一条消息,告知用户该站点对它的依赖性以及启用它的建议.


这是一个示例页面,其中的JS开/关与众不同.
请注意,我不必删除< noscript>页面中的标签.


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>
<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>