Is there a HTML opposite to <noscript>?

Is there a tag in HTML that will just present its web content if JavaScript is made it possible for? I recognize <noscript> functions vice versa around, presenting its HTML web content when JavaScript is switched off. Yet I would love to just present a kind on a website if JavaScript is readily available, informing them why they can not make use of the kind if they do not have it.

The only means I recognize just how to do this is with the document.write(); method in a manuscript tag, and also it appears a little bit unpleasant for huge quantities of HTML.

118
2022-06-06 12:25:14
Source Share
Answers: 6

Here is an instance for the surprise div means:

<!DOCTYPE html>
<html>
    <head>
        <meta charset="utf-8">
        <title></title>
        <style>
            *[data-when-js-is-on] {
                display: none;
            }
        </style>
        <script>
            document.getElementsByTagName("style")[0].textContent = "";
        </script>
    </head>
    <body>
        <div data-when-js-is-on>
            JS is on.
        </div>
    </body>
</html>

(You 'd possibly need to fine-tune it for inadequate IE, yet you understand.)

1
2022-06-07 04:37:58
Source

There isn't a tag for that. You would certainly require to make use of javascript to show the message.

Some individuals currently recommended making use of JS to dynamically set CSS noticeable. You can additionally dynamically create the message with document.getElementById(id).innerHTML = "My Content" or dynamically developing the nodes, yet the CSS hack is possibly one of the most uncomplicated to read.

0
2022-06-06 19:14:22
Source

You can have an unseen div that obtains revealed using JavaScript when the web page lots.

65
2022-06-06 12:41:36
Source

Alex's article come to mind below, nonetheless it is just relevant if you are making use of ASP.NET - maybe mimicked in JavaScript nonetheless yet once more you would certainly need to make use of document.write () ;

0
2022-06-06 12:41:29
Source

You can additionally make use of Javascript to load web content from an additional resource documents and also result that. That might be a little bit extra black box - is than you are seeking however.

1
2022-06-06 12:40:49
Source

You can set the presence of a paragraph |div to 'concealed'.

After that in the 'onload' function, you can set the presence to 'noticeable'.

Something like:

This message to be concealed unless javascript available.

0
2022-06-06 12:40:15
Source