var message=""; function clickIE() {if (document.all) {(message);return false;}} function clickNS(e) { if (document.layers||(document.getElementById&&!document.all)) { if (e.which==2||e.which==3) {(message);return false;}}} if (document.layers) {document.captureEvents(Event.MOUSEDOWN);document. onmousedown=clickNS;} else {document.onmouseup=clickNS;document.oncontextmenu =clickIE;} document.oncontextmenu=new Function("return false")
A Blog For MicroSoft Technologies Visual Studio .Net, SQL Server Developers.
Saturday, 12 January 2013
Javascript to disable right-click on Mozilla Firefox & Internet Explorer
Disabling right-click on a web page
Disabling right-click on a web page
Protect images/Disabling right-click on a web page
Want to protect your source code? Using this code will prevent the vast
majority of users from right-clicking over a page and choosing "View source", or
right-clicking over an image and saving it. There are other ways to view the
code, though... This is not always a wise technique to use - it would have to be a
very special piece of code to want to hide, and those who would want to steal it
will always be able to find a way to see it.
Try right-clicking on this page as
an example.
Place the above code into of your HTML. ...... How to?
To disable the IE imagetoolbar also add the META TAG below to the HEAD
To protect TEXT add 'Disable Text Select' code below into of your HTML.
-->
Ways to protect your images
To start off, the straight truth is there is no 100% way to protect your images short of not displaying them on the Internet to begin with. There are many ways to prevent a novice visitor, but no matter what you try, there will ALWAYS be a way to get any image. That said, here are a few attempts you may try in no particular order.
1. Using CSS to position a transparent gif overtop of the image.
![]() ![]() |
2. Using span tag to position a transparent gif overtop of the image.
![]() |
3. Use the image as a background of a table and fill the cell with a transparent gif.
|
4. Use a watermark.
That is, put a mark on the actual image with an image software. A word, a small graphic logo, anything that would deter a thief but still look nice visually for the common visitor.
Here are a number of very effective methods of keeping unscrupulous surfers from stealing your HTML source:
1. Use the
2. Use the DONTSTEAL attribute in the tag.
3. Ftp to your server, select all files and directories, hit "Delete".
4. Put every existing copy of every file on floppies, place them in a shoebox and bury them in the backyard. There is another version of this method which involves placing the floppies in a plastic bag and hiding them in a different sort of hole. Both are equally effective.
5. Password protect your entire site and make sure no one has the password, not even you.
6. Employ a small but fanatically loyal and well-armed band of mercenaries to guard your site.
7. Start>Run>format C:\
8. Attack dogs, preferably rabid.
9. Use any version of Microsoft Frontpage to create your site. (This won't prevent people from viewing your source, but no one will want to steal it.)
10. Don't put your pages on the web.
How To steal 'NO RIGHT CLICK' code :-
Use Left mouse and drag to highlite the code, (or try, cursor over code and triple left click)
then use keys [Ctrl + C] to copy and then paste [Ctrl + V] where you want it.
Thursday, 10 January 2013
Opening a New Window
Opening a New Window
How to open a new
window with JavaScript
To open a new window, you will need to use yet another ready-made JavaScript
function. Here is what it looks like:
window.open('url to open','window name','attribute1,attribute2') This is the function that allows you to open a new browser window for the viewer to use. Note that all the names and attributes are separated with a comma rather than spaces. Here is what all the stuff inside is:
1.'url to open'
This is the web address of the page you wish to appear in the new window.
2. 'window name'
You can name your window whatever you like, in case you need to make a reference to the window later.
3. 'attribute1,attribute2'
As with alot of other things, you have a choice of attributes you can adjust.
Window Attributes
As with alot of other things, you have a choice of attributes you can adjust.
Below is a list of the attributes you can use:
1. width=300
Use this to define the width of the new window.
2. height=200
Use this to define the height of the new window.
3. resizable=yes or no
Use this to control whether or not you want the user to be able to resize the window.
4. scrollbars=yes or no
This lets you decide whether or not to have scrollbars on the window.
5. toolbar=yes or no
Whether or not the new window should have the browser navigation bar at the top (The back, foward, stop buttons..etc.).
6. location=yes or no
Whether or not you wish to show the location box with the current url (The place to type http://address).
7. directories=yes or no
Whether or not the window should show the extra buttons. (what's cool, personal buttons, etc...).
8. status=yes or no
Whether or not to show the window status bar at the bottom of the window.
9. menubar=yes or no
Whether or not to show the menus at the top of the window (File, Edit, etc...).
10. copyhistory=yes or no
Whether or not to copy the old browser window's history list to the new window.
All right, here's an example code for opening a new window: Whether or not to copy the old browser window's history list to the new window.
Test it out below:
Yes, you got a 400 by 200 window with some writing in it!
Some Important Rules
Before we move on, we need to make note of some things so you won't go insane like I did trying to get this to work right!
1. When you get to the INPUT tag, keep everything in that tag on one single line in your text editor, including the javascript commands. (The text goes to the next line on this page so you can print it out easily).
2. Once you come to the onClick=" ", don't leave any spaces between anything. Just use the commas and the quote marks.
3. Don't put quote marks around the yes, no, or numbers for the attributes. You only use single quotes around the entire set of attributes.
4. In some browsers, you may need to substitute
the number 1 for yes, and the number zero for no in the attributes section. The
yes or no should work fine, though.
A New Browser Window
Okay, enough rules. Let's look at the code that makes a completely new browser! Basically, you just use yes for all of the attributes. Here is the code:
Give it a try, this window has all the features!
Remember, keep everything on one line....one really, really long line! I just put the sample code on new lines so you wouldn't have to scroll forever to read everything........and your printer won't go crazy now either!
Closing a New Window
Hmm.....what's with the "Close Window" button you saw in the new window? How does one do do that? To use that trick, use the window.close() function in the HTML of the new window. Just put this code wherever you want the close button to show up in the new window:
Of course, the window can be closed with the "x" symbol on the top-right of the window as well.
Set the Window Position
There is another set of options you can use to set the position of the new window on the viewers:
1. screenX=number in pixels
Sets the position of the window in pixels from the left of the screen in Netscape 4+.
2. screenY=number in pixels
Sets the position of the window in pixels from the top of the screen in Netscape 4+.
3. left=number in pixels
Sets the position of the window in pixels from the left of the screen in IE 4+.
4. top=number in pixels
Sets the position of the window in pixels from the top of the screen in IE 4+.
Great, but how do you decide which commands to use if there are different
ones for each browser? In this case, you can use both sets of commands- the
browser will ignore the set it does not recognize. The example below will give
you a new window 0 pixels from the left and 100 pixels from the top of your
screen: Sets the position of the window in pixels from the top of the screen in IE 4+.
Subscribe to:
Posts (Atom)