just copy everything inside your script tags now, and put in a .js file (with notepad). then link as shown
theEclipse
eclipse_web@hotmail.com
robacarp.webjump.com
**-Trying to build a documentation of a Javascript DOM, crossbrowser, of course. E-mail me if you know of any little known events and/or methods, etc.
The SRC attribute is only available in Javascript1.1 and later, so be aware that you'll be locking out users that have *ancient* browsers by using it. It may be a little silly to try to write for these older browsers in most circumstances, but I'm sure there are clients out there that put that requirement in their specs.
As Tom and eclipse said, it is _absolutely_ impossible to prevent people from seeing your code. This question has been asked and answered numerous times in this forum. In my opinion, it's a waste of time and energy implementing naive techniques with this as their end, even when they're applied to *sacred* code ;-)
There is a way, not perfect but pretty good. Put your code in a 1 pixel frame (You can try zero but some browsers don't like that), and everything else in a second frame. Include in the first frame the following function to run onLoad:
function
shut(){
if(parent.document.title == self.document.title) { document.location = "parent.htm"}
where parent.htm is the name of your parent frameset page. It will protect your code from most snoopers.
Carl
ps: You could probably also do away with the function and just keep the if statement, but I have not tested it, to accomplish the same thing.
Carl, that does not prevent anyone from viewing your source. It just obscures it a little. If someone really wanted it, they could get it trivially. For instance, they could see that you are using a frameset, copy the URL for your "hidden" frame, and paste it in their address bar. There is *NO* way to "lock away" your source.
Sincerely,
I'm having a hard time understanding what could be "sacred" about HTML or JavaScript code on one's page. The web is what it is due in large part to the practice of code "borrowing." Kevin
slanek@ssd.fsi.com
tanderso wrote
" For instance, they could see that you are using a frameset, copy the URL for your "hidden" frame, and paste it in their address bar. There is *NO* way to "lock away" your source."
Not true. The method I described above can be gotten around but not by simply doing this. I have used it with several 1000 students and only a few have gotten into the JavaScript.
Carl
Yes Iza, borrowing AND adapting is a much better expression. The point is, there is no reason to hide your HTML or JS code. Nothing in the code could be that sacred. I'm open to criticism though. If you can think of a reason I'd like to hear it.
Another thought, even if you could hide your code, it wouldn't take a genius to reverse engineer your page and get the exact same result. It could be done fairly easily. Kevin
slanek@ssd.fsi.com
and what's more, an algorithm doesn't belong to you even if YOU created it (at least here !!! only the FORM/SHAPE is protected)
anyway i agree with kevin, i guess we all learnt a few tricks in reading someone else's code (html or javascript or whatever) and that's not such a deal to share what you've finally learnt- i mean it's giving back what you have been given !
You might want to hide the code if it contained answers to questions, for example. Of course, you might want do other things to disquise the answers also. If you want to see my example at work go to
select any chapter and go to practice problems.
BTW I wrote a JavaScript password protection that only one person has been able to crack. View source won't do it! I am on the road so I don't have the URL handy but when I return I will post the URL if anyone is interested,
Carl
Very cool. So in a case like that, code-theft isn't really the issue. You're more concerned about students being able to cheat on the answers. Now that I can understand.
JavaScript is not meant to save any information in a way which disguises it from users. JavaScript is meant to manipulate HTML elements and events. If you want to have hidden information, save it on your server using CGI and access it at the correct time using CGI.
Sincerely,
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.