PDA

View Full Version : warning only for no right click?



lprag
12-18-2006, 12:47 AM
Hello,

Can someone please provide a script that will just present a copyright
warning message in any browser, when someone right clicks.

Thanks.

jscheuer1
12-18-2006, 03:36 AM
Not really a good idea. Your original material is copyrighted. If you suffer any significant harm through your copyrights being violated, you may sue. This is all the protection you need. If you want folks put on notice, post a copyright notice on the page. A right click script will be missed in many browsers and can cause problems with your page(s).

djr33
12-18-2006, 06:05 AM
If I were trying to steal something from a page, I'd just use Safari (the browser I happen to be using at the moment). I have yet to see a no right click script that works for it. It may be quite possible, but just haven't come across one that has that coded into it.

Shouldn't be that hard to make that pop up if you want it, though.

The javascript for it would be something like:

<... onClick="alert('&copy; 2006 Something.com')">

Just apply that to where the alert pops up in the javascript you are using.

*Not sure if &copy; works in javascript. In fact, I suspect it doesn't. Not sure how you'd display a copyright symbol in JS, then.

tech_support
12-18-2006, 07:39 AM
No it doesn't. Use
&#169;

And that will be kinda annoying.

jscheuer1
12-18-2006, 08:09 AM
It depends upon the situation, in an alert string:


\xa9

djr33
12-18-2006, 08:35 AM
Interest. What is that? (By name... what type of character naming is it?)

jscheuer1
12-18-2006, 02:07 PM
I really am not sure of the precise technical name. It is the 2 digit ASCII hex value of the character preceded by the special character \x. If you want to use the 4 digit Unicode value, precede it with \u - for that's:


\u00a9

Unicode is the same as ASCII (just add the two 0's to make it 4 hex value digits) until you get above two hex digits being required to express the character's value and can therefore be used for many more characters if the user agent can display them.

Twey
12-18-2006, 02:11 PM
*Not sure if &copy; works in javascript. In fact, I suspect it doesn't. Not sure how you'd display a copyright symbol in JS, then.It doesn't, but in the example you posted, it's also an HTML attribute, and will be parsed as such before being passed to the JS interpreter.

jscheuer1
12-18-2006, 02:34 PM
It doesn't, but in the example you posted, it's also an HTML attribute, and will be parsed as such before being passed to the JS interpreter.

Right. However, using the onclick attribute that way for a no right click alert isn't going to give the desired results.

djr33
12-18-2006, 09:54 PM
Right. I know it's not technically 'javascript', but I know that alerts behave differently than standard html, so I called it JS.

Thanks for the info, John.

Twey
12-18-2006, 10:32 PM
... huh?
However, using the onclick attribute that way for a no right click alert isn't going to give the desired results.Certainly.
Right. I know it's not technically 'javascript', but I know that alerts behave differently than standard html, so I called it JS.What isn't?

djr33
12-18-2006, 11:41 PM
The alert. That isn't just html... can it be accessed any other way than javascript? It has special coding, such as \n for a linebreak, which I see as much more similar to JS than HTML.

As for the onclick attribute, that was just an example of an alert. But you could just do <body onClick....>, right?

jscheuer1
12-19-2006, 03:43 AM
There are a number of things at issue in this thread. The original question/request was for a no-right-click alert. That cannot be done reliably and will add code to a page that will cause some problems in some browsers and will slow down loading of the page in all browsers. No-right-click is not required to protect anything on a page (see post #2 in this thread) and, in fact cannot.

Then came the issue of which character to use in an alert string to make the copyright symbol. I think the Unicode escaped:

\u00a9

would be the most universally applicable. The character itself or the hex escaped \xa9 will both work in most cases. I don't think any character or escape sequence will work 100% of the time in all cases in all browsers.

Then there is the matter of an HTML named entity - &copy; - in this case. That will work if it is parsed by the HTML parser before it is passed to the javascript interpreter, as is the case and as Twey pointed out, when the alert is itself a direct part of an HTML element's event, an inline event. If it is a part of a script however, the literal string '&copy;' will be used.

mwinter
12-19-2006, 02:36 PM
I really am not sure of the precise technical name.

Nothing special: a hexadecimal escape sequence.



It is the 2 digit ASCII hex value

Not ASCII. A Unicode code point. All strings are composed of sequences of 16-bit unsigned integers, each of which represent Unicode code points under the UTF-16 encoding scheme.



Unicode is the same as ASCII (just add the two 0's to make it 4 hex value digits) until you get above two hex digits being required to express the character's value ...

Not entirely true. There are only 128 ASCII characters in total, whereas the hexadecimal escape sequence provides for a range of 256.

The code points U+0000..00FF are the same as ISO/IEC 8859-1 (Latin-1), which in turn expands upon ISO/IEC 646:1996-IRV (ANSI X3.4 or ASCII). At U+0080 and above, one is beyond the scope of the latter.

Mike

chechu
12-19-2006, 02:47 PM
Read this thread:
http://www.dynamicdrive.com/forums/showthread.php?t=14403

jscheuer1
12-19-2006, 04:42 PM
Nothing special: a hexadecimal escape sequence.


Not ASCII. A Unicode code point. All strings are composed of sequences of 16-bit unsigned integers, each of which represent Unicode code points under the UTF-16 encoding scheme.


Not entirely true. There are only 128 ASCII characters in total, whereas the hexadecimal escape sequence provides for a range of 256.

The code points U+0000..00FF are the same as ISO/IEC 8859-1 (Latin-1), which in turn expands upon ISO/IEC 646:1996-IRV (ANSI X3.4 or ASCII). At U+0080 and above, one is beyond the scope of the latter.

Mike

Thanks for this bit of clarification. I relied upon my knowledge from the old BBS days. Then we referred to the 256 member character set as ANSI (including ASCII and 'high ASCII') but often thought of the ASCII set and the additional characters in what we called ANSI as separate sets, with one being called ASCII and the other ANSI - other times it was all just ASCII or ANSI. It was a semantic nightmare. Referring to it all (including those characters above 256) as Unicode points and breaking it out as to how many Unicode points are required, makes more semantic sense. But, ASCII (the 128 character set) itself cannot be defined solely this way (as a certain number of Unicode points, no more - no less), or can it?

mwinter
12-19-2006, 05:50 PM
... we referred to the 256 member character set as ANSI (including ASCII and 'high ASCII') but often thought of the ASCII set and the additional characters in what we called ANSI as separate sets, with one being called ASCII and the other ANSI - other times it was all just ASCII or ANSI. It was a semantic nightmare. Referring to it all (including those characters above 256) as Unicode points and breaking it out as to how many Unicode points are required, makes more semantic sense. But, ASCII (the 128 character set) itself cannot be defined solely this way (as a certain number of Unicode points, no more - no less), or can it?

Technically, probably not, but practically one might as well - at least when Unicode is familiar to the reader. The encoded values for each ASCII character map one-to-one onto the corresponding Unicode scalar values for those same characters. This is why a large number of documents encoded using UTF-8 are interchangeable as ASCII and vice versa: so long as each Unicode character is in the U+0000..007F range, it's encoded as a single 8-bit byte that's the same as its (zero-extended) ASCII counterpart.

Mike

lprag
12-25-2006, 03:45 PM
Hello,

Nobody answered my original question on a right click script.

I simply want a script that will give a pop up warning that the
page is copyright, along side the normal right click menu.

Any suggestions?

djr33
12-26-2006, 08:28 AM
<boby onrightclick="alert('warning: the contents of this page are copyrighted.');">
No clue if that works, though. :p

Here's a script from DD, modified like that.. untested, but the changes were simple...
<html>

<body>

<script language=JavaScript>
<!--

//Disable right mouse click Script
//By Maximus (maximus@nsimail.com) w/ mods by DynamicDrive
//For full source code, visit http://www.dynamicdrive.com

var message="Warning: the contents of this page are copyrighted.";

///////////////////////////////////
function clickIE4(){
if (event.button==2){
alert(message);
}
}

function clickNS4(e){
if (document.layers||document.getElementById&&!document.all){
if (e.which==2||e.which==3){
alert(message);
}
}
}

if (document.layers){
document.captureEvents(Event.MOUSEDOWN);
document.onmousedown=clickNS4;
}
else if (document.all&&!document.getElementById){
document.onmousedown=clickIE4;
}

document.oncontextmenu=new Function("alert(message);")

// -->
</script>

</body>

</html>
Basically took out all of the 'return false;' statements and changed the alert message.

chechu
12-26-2006, 09:25 AM
Here you will find the code from DD:http://www.dynamicdrive.com/dynamicindex9/noright.htm
(just change the text)

Read this about copyrights and functionality:
http://www.dynamicdrive.com/forums/s...ad.php?t=14403

djr33
12-26-2006, 10:13 AM
That is the same code I posted above (the second code, obviously), but I took out the 'return false' statements, which is what he wanted. He just wants an alert to pop up, too.