top button
Flag Notify
    Connect to us
      Site Registration

Site Registration

How can JavaScript codes be hidden from old browsers that don’t support JavaScript?

+1 vote
405 views
How can JavaScript codes be hidden from old browsers that don’t support JavaScript?
posted Aug 8, 2017 by Rajesh Jk

Share this question
Facebook Share Button Twitter Share Button LinkedIn Share Button

1 Answer

0 votes

To prevent old browsers from displaying your JS code, you can do the following:

Immediately after the opening tag, put a one-line HTML-style comment without the closing characters, so that the first two lines of your script would look like this:

<script type="text/javascript" language="JavaScript">
<!--
At the end of your script, put the following two lines:
//-->
</script>

Thus, your HTML file will contain the following fragment:

<script language="JavaScript">
<!--
Here you put your JS code.
Old browsers will treat it
as an HTML comment.
//-->
</script>

Old browsers will treat your JS code as one long HTML comment. On the other hand, new JavaScript-aware browsers will normally interpret JS code between the tags and (the first and last lines of your JS code will be treated by the JavaScript interpreter as one-line comments).

answer Aug 9, 2017 by Bharat Kumar
Similar Questions
+2 votes

Is there any way so that i will get to know about my variable is a number or not without using Javascript?

+1 vote

How can i prevent onclick button from multiple click until it's confirmation from javascript if(confirm ) condition.

Note:-Solutions could be easy but not able to track because i am naive in UI development, please help me out.

Here is button

<input type="button" onclick="return saveValues();" value="<?php echo "values" ?>" class="silver_button_big">

Respective javaScript call

var saveValues = function() {
         // some code                
        if(isModified() == false){
            jError("It is modified.");
            return;
            }        
             if(confirm("Are you sure")){
              $.post(base_url + 'google/update_values', {
               //some code               
            }
    };
...