is there any way to hide the code of a page using javascript or other language?
hide your code
| alalex wrote: |
| is there any way to hide the code of a page using javascript or other language? |
The actual html source, you can't hide, because that is how browser handle it. You can try to stop viewing the code with javascript like, if visitor press right mouse button comes a promt telling "Don't steal my source" etc. But this doesn't work if javascript is disabled.
You can't hide html source.
and, you know this button in the browser that allows you to see the web's code, it is dissabled on some webs, like in email services...
its part of a browser's GUI, you can never disable it through remote scripting means.
the least you can do is to house your site in a frame (thus view -> source gives the code of the frame) and redirects to this frame if pags are not loaded inside it, and prevent right clicking on page.
the least you can do is to house your site in a frame (thus view -> source gives the code of the frame) and redirects to this frame if pags are not loaded inside it, and prevent right clicking on page.
cool, i will keep looking for something else, if i find something i will post it here..
but thanks anyway.. the only problem is i HATE frames
thanks
but thanks anyway.. the only problem is i HATE frames
thanks
correct me if im wrong, but cant you disable the "right click not allowed" thing by just disabling javascript in the browser?
Even if right click is disabled, a user still can view the source of a page by going to "View" > "Page Source". So nothing can stop a user from stealing your source etc.
By the way, this is the code for disabling right click:
By the way, this is the code for disabling right click:
| Code: |
|
<html oncontextmenu="return false;"> |
This topic has come up before, and I don't quite get the point of hiding your code or preventing people from "stealing" your code.
Unless you're creating some sort of software that you're going to sell a license for, there's no reason to hide your code. The internet is a forum for exchanging information freely, and this should extend to information about how the internet and webpages work as well as the information conveyed by them. If someone wants to learn by looking at your code, why not let them?
With that aside...
Have you thought about using php instead of javascript? PHP is a server side scripting language, so it is limited in what you can convert from javascript to php. But, if you can script your functions in php they will not be viewable to the user because php is automatically parsed and converted to html output for the browser.
Also, I haven't got much experience with Javascript, so I don't know exactly how this would work. But... you can include javascript from an external .js file if I remember correctly. You might be able to restrict access to that file somehow.
I was looking through the phpbb source today and noticed they had a similar protection method. In the main files, a constant is defined. When one of the include files is accessed, if that constant is not defined (i.e. if you access the .php file directly or from another file), the script dies and nothing is outputted. Whether or not a similar method will work for javascript, I don't know. But good luck =)
- Walkere
Unless you're creating some sort of software that you're going to sell a license for, there's no reason to hide your code. The internet is a forum for exchanging information freely, and this should extend to information about how the internet and webpages work as well as the information conveyed by them. If someone wants to learn by looking at your code, why not let them?
With that aside...
Have you thought about using php instead of javascript? PHP is a server side scripting language, so it is limited in what you can convert from javascript to php. But, if you can script your functions in php they will not be viewable to the user because php is automatically parsed and converted to html output for the browser.
Also, I haven't got much experience with Javascript, so I don't know exactly how this would work. But... you can include javascript from an external .js file if I remember correctly. You might be able to restrict access to that file somehow.
I was looking through the phpbb source today and noticed they had a similar protection method. In the main files, a constant is defined. When one of the include files is accessed, if that constant is not defined (i.e. if you access the .php file directly or from another file), the script dies and nothing is outputted. Whether or not a similar method will work for javascript, I don't know. But good luck =)
- Walkere
o, cool, i thought that users could view your php scripts, and i was kind of worried because they would view my passwords to mySQL databases and other stuff like that..
thanks a lot!

thanks a lot!
(as I wrote in another similar thread)
This is an online convert tool:
HTML Obfuscator:
http://tool-galaxy.remiya.com/html/3.html
In this online tool (press the "HTML Obfuscator"-button), you can insert your html-code, and get a complete unreadable java script you can have on your web page instead. Your site will only works with javascript enabled browsers. If javascript is disabled your page will not show at all, neither will it show your real source code.
Is it fool proof? I don't know. Will it make your site slow? I don't know that either. I haven't tried that tool my self, nor will I. But I think that if someone can read your source code from this, they probably do not need to copy someone elses html code anyway.
Good luck hiding your source whatever reason you may have. Remember not to publish anything on the web, that is important that other people can not see.
This is an online convert tool:
HTML Obfuscator:
http://tool-galaxy.remiya.com/html/3.html
In this online tool (press the "HTML Obfuscator"-button), you can insert your html-code, and get a complete unreadable java script you can have on your web page instead. Your site will only works with javascript enabled browsers. If javascript is disabled your page will not show at all, neither will it show your real source code.
Is it fool proof? I don't know. Will it make your site slow? I don't know that either. I haven't tried that tool my self, nor will I. But I think that if someone can read your source code from this, they probably do not need to copy someone elses html code anyway.
Good luck hiding your source whatever reason you may have. Remember not to publish anything on the web, that is important that other people can not see.
I wanted to reduce the size of my script file so I wrote a program that replaces all variable and function names with new names based on a base number system of 26. This also reduces readability.
Heres what an application function looked like after that:
function mgh ( hgs )
{
var dbs= new Array();
var nrq = MyPage.historyInfo.value.split("|");
var mgc="";
var mwd=false;
var mwz=1;
var mws="";
while (mwz < nrq.length)
{
dbs=nrq[mwz].split("!");
if(dbs[0]==hgs && dbs[3]=="0" && dbs[4]=="0")
{
if(mgc.indexOf(dbs[0] + "!")==-1)//525
{
mgc=mgc + dbs[0] + "!";
}
else
{
mws= mws + "|" + nrq[mwz];
}
}
else
{
if(qtg (hgs,dbs[0]) && dbs[3]=="0" && dbs[4]=="0" && (mgc.indexOf(dbs[0] + "!")==-1))
{
mgc=mgc + dbs[0] + "!";
}
else
{
if(dbs[0]==hgs && mwd==false)
{
mws= "|" + nrq[mwz] + qrz (dbs[0],"!" + dbs[1] + "!" + dbs[2] + "!" + dbs[3] + "!" + dbs[4] ) +
mws + "|" + nrq[mwz];
mwd=true; }
else
{
mws= mws + "|" + nrq[mwz];
}
}
}
mwz++;
}
MyPage.historyInfo.value=mws;
MyPage.changed.value="1";
hhp= new Array();
ght (MyPage.historyInfo.value);
}
I'm not sure if it will still work after I put it through the obfuscator because function names need to be referenced!
Heres what an application function looked like after that:
function mgh ( hgs )
{
var dbs= new Array();
var nrq = MyPage.historyInfo.value.split("|");
var mgc="";
var mwd=false;
var mwz=1;
var mws="";
while (mwz < nrq.length)
{
dbs=nrq[mwz].split("!");
if(dbs[0]==hgs && dbs[3]=="0" && dbs[4]=="0")
{
if(mgc.indexOf(dbs[0] + "!")==-1)//525
{
mgc=mgc + dbs[0] + "!";
}
else
{
mws= mws + "|" + nrq[mwz];
}
}
else
{
if(qtg (hgs,dbs[0]) && dbs[3]=="0" && dbs[4]=="0" && (mgc.indexOf(dbs[0] + "!")==-1))
{
mgc=mgc + dbs[0] + "!";
}
else
{
if(dbs[0]==hgs && mwd==false)
{
mws= "|" + nrq[mwz] + qrz (dbs[0],"!" + dbs[1] + "!" + dbs[2] + "!" + dbs[3] + "!" + dbs[4] ) +
mws + "|" + nrq[mwz];
mwd=true; }
else
{
mws= mws + "|" + nrq[mwz];
}
}
}
mwz++;
}
MyPage.historyInfo.value=mws;
MyPage.changed.value="1";
hhp= new Array();
ght (MyPage.historyInfo.value);
}
I'm not sure if it will still work after I put it through the obfuscator because function names need to be referenced!
I would recommend using php instead of javascript if you want to hide your code. I think this was discussed already.
-gs
-gs
coool, my oly problem was with mySQL connection passwords and usernames... but thanks anyway!
