Link to home
Start Free TrialLog in
Avatar of duncanb7
duncanb7

asked on

How to let the code hidden from the viewers in Web browsers

Dear Experts,

I just write one html code file as attached, and it run in IE broswer as simple html.file.

The question how I can avoid the code to be seen by other users except the code output ?
I have google it, someone say I need to switch the html code to asp and php code.
And I test the php and asp code before in W3C school webiste, but php and asp code is also easily seen by viewers in web.

Any suggestion for internet language to hidding the code  at least some part of it ?

If possible, could you provide a simple code for study or good wesite to start.

Please advise

Duncan
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<style type="text/css"> 
* {
font-size:15px;
font-family:Tahoma, Arial, 'Trebuchet MS', Verdana;
}
 
html,body {
background-color: #FFFFFFF ;
margin:1px;
padding:0;
height:100%;
 
}
 
</style>
<title >Testing Site</title>
 
 
<script type="text/javascript"> 
 
 
 
// e - event, el - element, fn- callback function
function checkEnter(e, el,fn) {
    var key=e.keyCode || e.which;
    if (key==13){
       fn();
el.value='';
return false;
    }
    return true;
}
 
function formSubmit() {
 
  var my_val = document.getElementById('text1').value;
var xmlhttp = false
if (window.XMLHttpRequest)
  {// code for IE7+, Firefox, Chrome, Opera, Safari
  xmlhttp=new XMLHttpRequest();
//alert("XMLHTTP Exists!");
  }
else
  {// code for IE6, IE5
  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
 
// check if value is empty
  if ( my_val.length > 0) { 
 
xmlhttp.open("GET", "http://www.exampledomain.com/"+ my_val +".html?Load",true);
xmlhttp.setRequestHeader("Cache-Control", "no-cache");
 xmlhttp.onreadystatechange=function() {
  if (xmlhttp.readyState==4) {
   if (xmlhttp.status==200) {//alert("URL Exists!");
parent.mainFrame.document.location.href="http://www.exampledomian.com/"+ my_val +".htm?Load"+new Date().getTime();
var box=document.getElementById("text1");
box.focus();
 
 
}
  
 
    else if (xmlhttp.status==404) alert("File  doesn't exist!")
     else alert("Status is "+xmlhttp.status)
  }
 }
 xmlhttp.send(null)
 
 
 
 
//document.write("This is my first JavaScript!");
 
 
}
}
function init()
{
  parent.mainFrame.document.location.replace( "http://www.exampledomian.com/data.html" );
var box=document.getElementById("text1");
box.focus();
}
 
</script>
</html>

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of Aaron Tomosky
Aaron Tomosky
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Anything you use to put a page in my browser can be found and downloaded.  'Hiding' code does not increase your security at all.  Any method of hiding code just hides it from the people who mostly don't care.  The people who might care, from crooks to government agencies, have ways of seeing your code.
Avatar of duncanb7
duncanb7

ASKER

how can I call javascript function so people could not read my code ?
I mean I put all of my code into javascript function and call it on

init is javascript script file stored in my domain

<body init():>

<body>

 IS it possible, I have seen a lot of website , we cound not see their code because
they call it in javascript function and in asp ?
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
ASP, ASP.NET and PHP are server side languages and you can't see that code.  However, they send HTML to the browser and that can be seen along with any javascript and CSS.  If the browser can't 'see' it, it can't be executed.

There are things you can do on the server and things that have to done in the browser.  Anything done in the browser can be seen.
aarontmosky,

Clarify it a little bit, you mean, even I stored the script code into other js file stored in my doma in site.
People could also download it, Is it right ? but I don't put it into my ftp directory, how they download.

And if using firebug add-on firefox, please could read all hidden javascritp code, is it right ?

in other words, if what you said correct,  the only way to hidden the code is converting all javascript code
into php or asp code so people could not read it , Is it right ?
Javascript has to be stored where it can be downloaded or else the browser can't download it and run it.  For the browser to run it, it has to be listed in the source code for the web page.  I can look at the source by clicking on "View Source" and get the location of the javascript file and then download it.
today i test it with firebug, debugger , all code could been seen even asp file

So in other words, if what you said correct,  the only way to hidden the code is converting all javascript code
into php so people could not read it , Is it right ?
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
You can only hide server-side stuff.  Like the HTML, any javascript or executed by the client will also be visible.  If you dig around in the browser cache you can find it all.
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Th banks for all of you to reply this
email, more understanding
to code hidden