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.

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

Here is an instance for the surprise div means:

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

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

2022-06-07 04:37:58

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.

2022-06-06 19:14:22

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

2022-06-06 12:41:36

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 () ;

2022-06-06 12:41:29

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.

2022-06-06 12:40:49

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.

2022-06-06 12:40:15