开发者

Enable Javascript Prompt

I have a page containing much contents. The page may display a custom error message if JavaScript is disa开发者_如何学JAVAbled. The page must not display anything else other than the prompt message. I am posting an image, which is similar to an error prompt I mean. I have an error prompt with some images in my mind..

Enable Javascript Prompt

How can I make this possible?


The general idea is that you would put your message HTML (no reason to use an image, text will work just fine) inside noscript tags like this:

<noscript>You must enable Javascript in order to use this site.</noscript>

If you want the noscript HTML to obscure/hide the entire rest of the page, then you will need to make sure whatever it is takes up the entire page and is on top. You could do that with something like this:

<noscript>
    <div id="noscript" style="position: absolute; top: 0; left: 0; background-color: #FFF; z-index: 999; height: 100%; width: 100%; text-align: center; padding-top: 50px;">
    You must enable Javascript in order to use this site.
    </div>
</noscript>

Here's a jsFiddle that shows how the noscript div works. The fiddle doesn't include the actual <noscript> tag because the fiddle won't work without JS, but it shows you how the absolutely positioned div works to block all other content. Scroll down in the HTML area of the fiddle to see the noscript div HTML (which is as I have copied into this post).


Your question isn't really clear but what I think you want to do is:

display an error message when a user hasn't JS enabled.

If so you can add an overlay to your page with a white background and your error message on it.

In the head section of your page you can add (very very simple example):

<script>
  // js code to remove the message
</script>

If I didn't understand your question please say so.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜