Go Back   CodingForums.com > :: Client side development > JavaScript programming

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 02-02-2005, 11:56 PM   PM User | #1
ImperialSpider
Regular Coder

 
Join Date: Jan 2004
Location: San Antonio, TX
Posts: 131
Thanks: 1
Thanked 0 Times in 0 Posts
ImperialSpider is an unknown quantity at this point
Question continuous right-clicks brings new alerts, then close window

What would the script be for this...

when you right click anywhere in the webpage, a customized alert pops up, after clicking ok, you right click again, this time a different customized alert pops up, and so on and so on, however after you right click 7 or 8 times, the webpage closes. I remember seeing this while surfing around, and thought that was a cool thing to have, but it was a long time ago, and I dont remember the website to give a script, or even look at it to try to figure it out. can anyone help with this? I would like to put that script to use.

PS...I understand that all someone has to do is click View, Source to see it, but I am not trying to hide my script, just present a cool effect.

Thanks to anyone who can direct me, or get me this script.

Imperial Spider
ImperialSpider is offline   Reply With Quote
Old 02-03-2005, 12:25 AM   PM User | #2
Brandoe85
teh Moderatorinator


 
Join Date: Sep 2004
Location: USA
Posts: 2,472
Thanks: 4
Thanked 40 Times in 40 Posts
Brandoe85 will become famous soon enough
You realize unless the page was opened with javascript, you will not be able to close the window...
But, Heres a script you can look at...
Code:
<script type="text/javascript">
function noClicky(e)
{
var browser = navigator.appName.substring (0, 9);
var eventnum = 0;
	if(browser == "Microsoft")
		eventnum = event.button;
	else if(browser == "Netscape")
		eventnum = e.which;

	if(eventnum == 2 || eventnum == 3)
	{
		alert("No right click");
		return false;
	}
	return true;
}
</script>
__________________
-Brando
Why using tables for eating is stupid!
Brandoe85 is offline   Reply With Quote
Old 02-03-2005, 12:39 AM   PM User | #3
ImperialSpider
Regular Coder

 
Join Date: Jan 2004
Location: San Antonio, TX
Posts: 131
Thanks: 1
Thanked 0 Times in 0 Posts
ImperialSpider is an unknown quantity at this point
hey

I tried that script, ... I put it in the Head section, and but it did not work, so I put it in the body section... Again, it did not work, it didn't do anything. Is there something missing in the script? I copied, and pasted the script as is. maybe, I am supposed to add something, and I just don't know it, or where to put my info in. Can you help me a little further?

Thanks,

ImperialSpider
ImperialSpider is offline   Reply With Quote
Old 02-03-2005, 12:49 AM   PM User | #4
Brandoe85
teh Moderatorinator


 
Join Date: Sep 2004
Location: USA
Posts: 2,472
Thanks: 4
Thanked 40 Times in 40 Posts
Brandoe85 will become famous soon enough
<body onmousedown="return noClicky(event);">
__________________
-Brando
Why using tables for eating is stupid!
Brandoe85 is offline   Reply With Quote
Old 02-03-2005, 01:00 AM   PM User | #5
ImperialSpider
Regular Coder

 
Join Date: Jan 2004
Location: San Antonio, TX
Posts: 131
Thanks: 1
Thanked 0 Times in 0 Posts
ImperialSpider is an unknown quantity at this point
that did something

It got the "NO RIGHT CLICK" to come up, but how would I add a custom script, for when the user right clicks a second time, and another for the third time, and so on...? I understand I can't close the window, but I would still like to have different alerts for each time the user tries to right click. even if it loops around after a certain number of times. I would like it to have at least 5 different alerts.

Can this be done?

Please bear with me, as I am not very experienced in js yet.

Im just looking to learn a few scripts for now.

Thanks,

Imperial Spider
ImperialSpider is offline   Reply With Quote
Old 02-03-2005, 02:12 AM   PM User | #6
hemebond
Senior Coder

 
Join Date: Jul 2004
Location: New Zealand
Posts: 1,315
Thanks: 0
Thanked 2 Times in 2 Posts
hemebond is an unknown quantity at this point
Quote:
Originally Posted by ImperialSpider
I remember seeing this while surfing around, and thought that was a cool thing to have
You are mistaken sir. This is the crappiest, most annoying, worthless, non-effective piece of crap you can put on a web page.
hemebond is offline   Reply With Quote
Old 02-03-2005, 02:38 AM   PM User | #7
ImperialSpider
Regular Coder

 
Join Date: Jan 2004
Location: San Antonio, TX
Posts: 131
Thanks: 1
Thanked 0 Times in 0 Posts
ImperialSpider is an unknown quantity at this point
Angry How Rude!

Hemebond.

I am not sure if you are just wanting to start something with me or if you are tired of reading requests from people who just want to learn a thing or two for their websites, but whatever your problem is, and whatever the reason...I am not part of it...Please, only respond if you can give a helpful answer, not a "personal opinion" about someones question. I know that I have never given you any reason to reply to my message this way, but if that is all you are going to do, please do not reply further...to my questions anyway...I am only here to learn, not to get into any arguments over an "opinion." If you can help with a script, or an Idea, please do so, but noone, including myself deserves to be talked to in this manner. I hope the admins are reading these, because there is certainly no excuse, or cause for your reaction to my question. I hope the rest of your day, week, and even the rest of your year gets better and better for you, but please don't reply to me like that again.

Imperial Spider
ImperialSpider is offline   Reply With Quote
Old 02-03-2005, 03:31 AM   PM User | #8
hemebond
Senior Coder

 
Join Date: Jul 2004
Location: New Zealand
Posts: 1,315
Thanks: 0
Thanked 2 Times in 2 Posts
hemebond is an unknown quantity at this point
You seem to have misinterpreted me. I was not attacking you, nor being rude. I was stating, very matter factly, that what you are trying to achieve is one of the most despised uses of Javascript possible. Had you done a search of these very forums, you would have found many posts stating the exact same thing.

This is not an opinion. It is a fact. This use of Javascript is pointless and annoying.
hemebond is offline   Reply With Quote
Old 02-03-2005, 04:25 AM   PM User | #9
ImperialSpider
Regular Coder

 
Join Date: Jan 2004
Location: San Antonio, TX
Posts: 131
Thanks: 1
Thanked 0 Times in 0 Posts
ImperialSpider is an unknown quantity at this point
Thumbs down I did not misinterpret you

Quote:
Originally Posted by hemebond
You seem to have misinterpreted me. I was not attacking you, nor being rude. I was stating, very matter factly, that what you are trying to achieve is one of the most despised uses of Javascript possible. Had you done a search of these very forums, you would have found many posts stating the exact same thing.

This is not an opinion. It is a fact. This use of Javascript is pointless and annoying.
That is exactly how I took your meaning, AND...it IS an "OPINION", which, I concede that, many people may share, BUT, just because something is in the popular opinion, does not make it a FACT! If you would have read my ENTIRE question, you would see that I am asking for a script which gives varying alerts when right clicking multiple times. I ALSO stated that I am NOT trying to hide my script. I saw it on another website and I thought it was a cool effect. This is MY opinion, and I only wanted to see if someone could help me with that script. Coming on, and trashing someone's question without FULLY reading it is not helping ANYBODY to learn. By the way, YES, I did do a search before asking the question, and NONE of the results asked "the exact same thing", nor answered my original request. I also ran the requests through other search engines such as "google", "yahoo", "msn" "searchalot" and "alta vista". Again, NONE of them gave me what I was looking for.

NOW... do you, or does anyone, know of a script which would answer my ORIGINAL request??? (minus the closing of the browser, of course, since that was already answered.)

Imperial Spider
ImperialSpider is offline   Reply With Quote
Old 02-03-2005, 04:39 AM   PM User | #10
Brandoe85
teh Moderatorinator


 
Join Date: Sep 2004
Location: USA
Posts: 2,472
Thanks: 4
Thanked 40 Times in 40 Posts
Brandoe85 will become famous soon enough
Erm, I'll put something out there, and you can look at it, and figure out what you need. Probably other ways to do it, but i'd just use a counter to figure how many times they've clicked...
Code:
<script type="text/javascript">
var count = 0;
function noClicky(e)
{
var words = new Array(5);
words[0] = "no";
words[1] = "yes";
words[2] = "why";
words[3] = "what";
words[4] = "when";
words[5] = "ok";
var browser = navigator.appName.substring (0, 9);
var eventnum = 0;
	if(browser == "Microsoft")
		eventnum = event.button;
	else if(browser == "Netscape")
		eventnum = e.which;

	if(eventnum == 2 || eventnum == 3)
	{
		if(count <= 5)
		{
			alert(words[count] + "\n number " + count);
			count++;
		}
		return false;
	}
	return true;
}
</script>
__________________
-Brando
Why using tables for eating is stupid!
Brandoe85 is offline   Reply With Quote
Old 02-03-2005, 06:56 AM   PM User | #11
ImperialSpider
Regular Coder

 
Join Date: Jan 2004
Location: San Antonio, TX
Posts: 131
Thanks: 1
Thanked 0 Times in 0 Posts
ImperialSpider is an unknown quantity at this point
Smile that is OH SO CLOSE to what I want

Thanks for replying Brandoe85, That is what I was looking for, but is there a way to make it loop itself after the 5th message?

In other words, I want to have it loop back to the first message after it finishes with the fifth one and continue again and again. The way it is now is cool, but on the 6th right click, the menu comes up. Please dont misunderstand me, I am not trying to "hide" my source code, I just want to play with the code to learn. But, this is Great!
ImperialSpider is offline   Reply With Quote
Old 02-03-2005, 07:06 AM   PM User | #12
Brandoe85
teh Moderatorinator


 
Join Date: Sep 2004
Location: USA
Posts: 2,472
Thanks: 4
Thanked 40 Times in 40 Posts
Brandoe85 will become famous soon enough
Just set the count variable back to 0...like this:
Code:
<script type="text/javascript">
var count = 0;
function noClicky(e)
{
var words = new Array(5);
words[0] = "no";
words[1] = "yes";
words[2] = "why";
words[3] = "what";
words[4] = "when";
words[5] = "ok";
var browser = navigator.appName.substring (0, 9);
var eventnum = 0;
	if(browser == "Microsoft")
		eventnum = event.button;
	else if(browser == "Netscape")
		eventnum = e.which;

	if(eventnum == 2 || eventnum == 3)
	{
		if(count <= 5)
		{
			alert(words[count] + "\n number " + count);
			count++;
		}
		if(count >= 6)
		{
			count = 0;
		}
		return false;
	}
	return true;
}
</script>
__________________
-Brando
Why using tables for eating is stupid!
Brandoe85 is offline   Reply With Quote
Old 02-03-2005, 07:13 AM   PM User | #13
rmedek
Senior Coder

 
Join Date: Nov 2003
Location: Minneapolis, MN
Posts: 2,879
Thanks: 2
Thanked 65 Times in 56 Posts
rmedek is on a distinguished road
Quote:
Originally Posted by ImperialSpider
Please dont misunderstand me, I am not trying to "hide" my source code, I just want to play with the code to learn.
I don't think the issue Hemebond had was necessarily disabling viewing the source. Stopping a right-click in any way is using Javascript to break a user's browser and interface. That use of JS is pretty much frowned upon by the web community. Just thought you should know.

Maybe a better use of this code would be to redirect a user to another page after failing a password attempt after five tries, or something similar?
__________________
drums | web
rmedek is offline   Reply With Quote
Old 02-03-2005, 07:43 AM   PM User | #14
ImperialSpider
Regular Coder

 
Join Date: Jan 2004
Location: San Antonio, TX
Posts: 131
Thanks: 1
Thanked 0 Times in 0 Posts
ImperialSpider is an unknown quantity at this point
Thumbs up Thank you

Thank you Brando. That is exactly what I was wanting...And see, I even learned something, (how to loop an alert message) which is all I wanted to do in the first place. (not learn to loop, but simply to learn <anything> by doing.) I only needed a little instruction.

rmedek, I understood where hemebond was coming from, it was the 'manner' of how he stated it is what I took offense to. I am here to learn, and your explanation of "breaking the users browser, or interface" taught me something as well. I certainly did not know that, and I appreciate your sharing it with me. You shared it in a "constructive" way, and that is the way I think it should be done. Had hemebond advised me of that fact, instead of saying "This is the crappiest, most annoying, worthless, non-effective piece of crap you can put on a web page." I know for a fact that I would have taken heed to the warning, and would not have "got on a soapbox". I appreciate you filling me in on this...I am new, and still learning things. Hopefully, I can learn much more.

Hemebond, I hope you understand, that I AM open to criticizm, but it must be CONSTRUCTIVE criticizm, not the type that discourages someone from trying to learn. I apologize to you and everyone in the community if I came off in any bad way.

Imperial Spider
ImperialSpider is offline   Reply With Quote
Old 02-03-2005, 11:24 AM   PM User | #15
jbot
Senior Coder

 
Join Date: Feb 2004
Location: Edinburgh
Posts: 1,352
Thanks: 0
Thanked 0 Times in 0 Posts
jbot is an unknown quantity at this point
Quote:
Originally Posted by ImperialSpider
I AM open to criticizm, but it must be CONSTRUCTIVE criticizm, not the type that discourages someone from trying to learn. I apologize to you and everyone in the community if I came off in any bad way.
and we apologise too for any confusion engendered by awkward statements posted albeit in good spirit. nonetheless, it should be noted that some users on this forum (myself included) are fed up of seeing requests for destructive scripts such as no-right-click ones. consquently it's all too easy for that frustration to spill over into what seems a rant.

however, as Hemebond pointed out, he wasn't trying to be personal with you. having posted in a public forum you invited observations from fellow forum users, the sentiments of which may or may not always be to your liking. as such, while opinions expressed here are nothing more than personal comments, they are still not attacks on you personally.

in the future please don't over-react. we don't a flame war starting up because of clumsy coding criticism. it cuts both ways, yanno.
__________________
*keep it simple (TM)
jbot is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 07:21 AM.


Advertisement
Log in to turn off these ads.