It's possible to disable an entire page html if the js is disabled on the browser of the user?
EDIT:
Thank you all for the answers and ments! However, what I mean is: I want that the page is replaced with something else, like an image, in that case.
It's possible to disable an entire page html if the js is disabled on the browser of the user?
EDIT:
Thank you all for the answers and ments! However, what I mean is: I want that the page is replaced with something else, like an image, in that case.
- not exactly a duplicate, but this thread will answer your question: stackoverflow./questions/6724515/… – durbnpoisn Commented May 23, 2016 at 18:49
- Do you mean disable a link to page? Or what do you mean exactly by "disable"? – Steven B. Commented May 23, 2016 at 18:50
- You'll probably need the page to render the replaced content by default with a JS call that actually swaps that out for the real content. If JS is disabled, the call won't go through and the failover content is shown, but if the JS call is successful then it would show the proper content – theaccordance Commented May 23, 2016 at 19:00
- I edited the question. Sorry if I wasn't clear enough. – CCT Commented May 23, 2016 at 19:00
- @Yosvel's answer is what you want. – Seth Commented May 23, 2016 at 19:17
2 Answers
Reset to default 7The noscript
tag defines an alternate content for users that have disabled scripts in their browser or have a browser that doesn't support script.
You can do something like this in your html body to display whatever image you want to show:
<noscript>
<style type="text/css">
.wrapper {display:none;}
</style>
<div>
<img src="src/to/your/image.png" alt="You don't have javascript enabled">
</div>
</noscript>
The css inside the noscript
tag will hide the html content inside the wrapper
class.
Not that I am aware of. Somewhere somehow you need to tell the browser to prevent the action/event linked to it, eg returning false, which is a task for javascript. I can e up with two alternatives:
Make all anchors dummies and correct them when JS is turned on:
<a href="#" data-href="/actual-url">foo</a>
$('a').each(function(){ this.href = $(this).data("href");} // * jQuery for simplicity
Put an layer on top of the anchor, which you can remove with JS.
.BlockedAnchor a{ position: relative; }
.BlockedAnchor a:before{
position: absolute;
display: block;
top: 0;
left: 0;
width: 100%;
height: 100%;
}
$('body'removeClass("BlockedAnchor");