Write content from server if JavaScript is not enabled

I am working on a project that by default loads content through AJAX.

I want him to check if JS (or SE-bot) is disabled, and if so, then statically static through PHP.

Is there any way to do this? I do not think that the noscript tag will work here, as the page will be empty for non-JS users or bots.

Also, doing a redirect to another page, for me this does not make sense, since links to the original page will not be taken into account by search engines and will not be able to index this page, since they will be redirected.

+3
source share
5 answers

JS? html- , JS, AJAX. , . URL- .

+2

, JavaScript.

, , JS, , hava a script , AJAX cookie, AJAX, , noscript , AJAX, , - , , cookie, JavaScript.

+4

<noscript> html.

. IE, Firefox, Opera, Chrome Safari.

:

<script type="text/javascript">
document.write("Hello World!")
</script>
<noscript>Your browser does not support JavaScript!</noscript>

, <meta>, , javascript ( ):

<script type="text/javascript">
document.write("Hello World!")
</script>
<noscript>Please wait while you're being redirected to the no-script version...
<META http-equiv="refresh" content="1;URL=http://yoursite/index.php?version=noscript">
</noscript>
+1

: ( CSS DOM node)

1) CSS:

css , JS.

Onload, JavaScript "none".

  • JS , .

onload : elObj.style.display:none;.

noscript, -, JavaScript, , , , .

2) Node :

, JavaScript onload.

  • Bots Non-JS , .
  • JS , .

, , , "nonjs".

, :

XDOM.deleteNode = function(node) {
    if (!node || typeof node != "object") {return;}
    var trashcan = XDOM.getElementById('xdomtrashcan');
    if (!trashcan) {
        trashcan = document.createElement('DIV');
            // quick and dirty property set:
        trashcan.id = 'xdomtrashcan';
        trashcan.style.display = 'none';
        document.body.appendChild(trashcan);
     }
     trashcan.appendChild(node);
     trashcan.innerHTML = ""; //empty the trash
  };
  • (XDOM . XDOM.getElementById. - .)
+1

"" - , , javascript cookie. , HTML-, AJAXy , cookie.

A variation of this would be to publish the URL of the landing page, which sets (or does not set) a cookie with an "onload" script and redirects HTML to the data page.

0
source

Source: https://habr.com/ru/post/1709138/


All Articles