Question:
How can you disable the browser to view the code?
Answer:
Writing codes within the <! -- //-- > Tag. Source: CoolInterview.com
well we can use Querystring to secure our page...... from unauthorized person Source: CoolInterview.com
Answered by: Rupinder sethi | Date:
| Contact Rupinder sethi
Use of <!-- ... --> makes no sense these days. I prefer to hide menu bar, address bar and disable right-click, if you really dont want the user to show your code. Source: CoolInterview.com
Answered by: Priyank | Date: 11/12/2009
| Contact Priyank
No Right Click Scripts These scripts stop users from right-clicking, where the "View Source" function is located.
Cons:
* Notoriously hard to get working across browsers and to actually work properly. * The right-click menu, or context menu, includes many helpful tools for users, including navigation buttons and the "Bookmark Page" button. Most users don't take kindly to having their browser functionality disabled and are inclined not to revisit such pages. * The View Source function is also available through the top Menu. At the main menu bar at the top of your browser, select View, and then in the sub-menu, you'll see "View Source" or something similar. Also, there are keyboard shortcuts like Ctrl+U that can be used to view source. All this method does is add about a two second delay to someone trying to view your source and it does irritate users who aren't trying to view your source.
"JavaScript Encryption" This is by far the most popular way to try to hide one's source code. It involves taking your code, using a custom made function to "encrypt" it somehow, and then putting it in an HTML file along with a function that will decrypt it for the browser. A User is able to view the source, however, it isn't understandable.
Cons:
* Your website is only usable for users with JavaScript enabled. This rules out search engines, users who've chosen to disable JavaScript, and users using a textual browser (such as the blind) that doesn't have JavaScript capabilities. Remember, JavaScript is a luxury, not a necessity on the web. * You have to include a means of decrypting the page so the browser can display it. Someone who understands JavaScript can easily decrypt the page. * Many browsers provide alternative ways around this. Some, like Netscape 7.0, allow you to save the page, decrypted for easy viewing later. Others, like FireFox, include tools like the DOM Inspector, which allows you to easily view and copy the XML of the page, decrypted. Source: CoolInterview.com
Answered by: praveen | Date: 11/29/2009
| Contact praveen
var isnn,isie if(navigator.appName=='Microsoft Internet Explorer') //check the browser { isie=true }
if(navigator.appName=='Netscape') { isnn=true }
function right(e) //to trap right click button { if (isnn && (e.which == 3 || e.which == 2 )) return false; else if (isie && (event.button == 2 || event.button == 3)) { alert("Sorry, you do not have permission to right click on this page."); return false; } return true; }
function key(k) { if(isie) { if(event.keyCode==17 || event.keyCode==18 || event.keyCode==93) { alert("Sorry, you do not have permission to press this key.") return false; } }
if(isnn){ alert("Sorry, you do not have permission to press this key.") return false; } }
if (document.layers) window.captureEvents(Event.KEYPRESS); if (document.layers) window.captureEvents(Event.MOUSEDOWN); if (document.layers) window.captureEvents(Event.MOUSEUP); document.onkeydown=key; document.onmousedown=right; document.onmouseup=right; window.document.layers=right;
Put this code in a file called security.js and reference it between the <HEAD> and </HEAD> tags of any html or asp page using: <Script language="JavaScript" src="security.js"></script> Source: CoolInterview.com
Answered by: Srinivasan Baskaran | Date: 6/5/2010
| Contact Srinivasan Baskaran
We can use this <!----- >
Regards, Nicku Source: CoolInterview.com
Answered by: nicku | Date: 8/13/2010
| Contact nicku
If you have the better answer, then send it to us. We will display your answer after the approval.
Rules to Post Answers in CoolInterview.com:-
- There should not be any Spelling Mistakes.
- There should not be any Gramatical Errors.
- Answers must not contain any bad words.
- Answers should not be the repeat of same answer, already approved.
- Answer should be complete in itself.
|