How do I hide javascript code in a webpage?

前端 未结 11 808
时光取名叫无心
时光取名叫无心 2020-11-22 17:17

Is it possible to hide the Javascript code from the html of a webpage, when the source code is viewed through the browsers View Source feature?

I know it is possibl

11条回答
  •  感情败类
    2020-11-22 18:03

    'Is not possible!'

    Oh yes it is ....

    //------------------------------
    function unloadJS(scriptName) {
      var head = document.getElementsByTagName('head').item(0);
      var js = document.getElementById(scriptName);
      js.parentNode.removeChild(js);
    }
    
    
    //----------------------
    function unloadAllJS() {
      var jsArray = new Array();
      jsArray = document.getElementsByTagName('script');
      for (i = 0; i < jsArray.length; i++){
        if (jsArray[i].id){
          unloadJS(jsArray[i].id)
        }else{
          jsArray[i].parentNode.removeChild(jsArray[i]);
        }
      }      
    }
    

提交回复
热议问题