473,789 Members | 2,300 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Disabling the right click function in the Popped up window!

1 New Member
Hi,

I used a short code to pop up a thumbnail in a new window for a gallery view. The problem is I would like to disable the right click function on the popped up / new window. How can I do this?

This is the code i used to pop up the window:

<a href="#"><img src="sml/17.jpg" alt="Garden!" style="" onclick="javasc ript:window.ope n('lrg/17.jpg','new',' width=850,heigh t=650,resizeabl e=no,directorie s=no,toolbar=no ,scrollbars=yes ,left=12,top=0' );" width="72" height="71" border="0" /></a>

Thank you!
Mar 26 '07 #1
2 2068
acoder
16,027 Recognized Expert Moderator MVP
Welcome to TSDN.

I assume you know how to disable right-click, but need to access the new window. Put your code into a function and call that in the onclick of the link. When calling window.open, keep a ref. to the window:
Expand|Select|Wrap|Line Numbers
  1. var newWin = window.open(...);
then you can newWin to access the new window.

There are lots of scripts that let you disable right-click. Find them using a simple Google search. However, anyone determined enough will easily be able to bypass this 'security' measure.
Mar 27 '07 #2
Gyanchand
35 New Member
hey try this

'Create a new page where the image will be placed. And popup this as the new window. Add this code in your script section of the popup page

Expand|Select|Wrap|Line Numbers
  1. function disable_right_click(e)
  2. {
  3.     var browser = navigator.appName.substring ( 0, 9 );
  4.     var event_number = 0;
  5.     if (browser=="Microsoft")
  6.         event_number = event.button;
  7.     else if (browser=="Netscape")
  8.         event_number = e.which;
  9.  
  10.     if ( event_number==2 || event_number==3 )
  11.         {
  12.         alert ("© ABC Co.Ltd. All rights reserved");
  13.         return (false);
  14.         }
  15.  
  16.     return (true);
  17. }
  18.  
  19. function check_mousekey ()
  20. {
  21.     var mouse_key = 93;
  22.     var keycode = event.keyCode;
  23.  
  24.     if ( keycode == mouse_key )
  25.         alert ( "© ABC Co.Ltd. All rights reserved" );
  26. }
  27.  
  28. function trap_page_mouse_key_events ()
  29. {
  30.     var browser = navigator.appName.substring ( 00, 9 );
  31.  
  32.     document.onmousedown = disable_right_click;
  33.  
  34.     if ( browser == "Microsoft" )
  35.         document.onkeydown = check_mousekey;
  36.     else if ( browser == "Netscape" )
  37.         document.captureEvents( Event.MOUSEDOWN );
  38. }
  39.  
  40. window.onload = trap_page_mouse_key_events;
Jul 21 '07 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

8
2035
by: George Hester | last post by:
In a page I have when the user left-clicks the page a Input box for a form gets the focus. But if the user right-clicks the page the Input box is not getting the focus. I'd like the Input box to get the focus no matter where on the page the user clicks be it right-click or left-click. Right now there is no context menu when the user right-clicks. Do you think that's the problem? Any ideas how to get this right-click left-click Input box...
20
2158
by: dukeleto | last post by:
I know this is an annoying thing on some sites. I have set some images in an online gallery to have their own java po up window that is set to be the same size as the image. I would like to set ONLY the pop up window so it does not allow th user to right click. Now I did a search, and found some options, but when you right click it gives the user an annoying pop up saying stuff like "you cant d
7
6205
by: Robert | last post by:
Can I programmatically disable the right click context menu?
13
22735
by: lightzizo | last post by:
All, How can I disable or remove the close button in the screen. thanks
12
2273
by: Nalaka | last post by:
Hi, I suddenly started getting a lot of errors from html validation (some CSS) so I followed the following instructions to disable it. If you'd rather not have these types of HTML validation errors show up in your error-list, you can disable this functionality by selecting the Tools->Options menu item in VS or Visual Web Developer. Select the TextEditor->Html->Validation tree option in the left-hand side of the
3
5509
by: surya52 | last post by:
I want to disable right click in my application.Here are my requirements. 1. I don't what to turn off shift click for the page. I want to turn it off for specific links. 2. I want shift-click to be replaced with a regular click. Meaning, when the user shift-clicks the link they will be taken to the "HREF" within the current browser window and NOT open up a new window. I did find a script that does something close to what I want, but it...
6
1837
by: emmajoh | last post by:
Hi I'm trying to disable IE contextmenu (on a right click) as I want to create my own. The problem is that since I've installed the latest version of the google desktop, the script doesn't work. No other script I found on the Internet is working anymore. As you can see below, I've tried to catch every event I'm aware of: ___________________________
5
1957
by: hp_1981 | last post by:
Hi Is there anyway avoiding users to save my web pages? this idea came to my mind when I tried to save a web page, but in the middle of saving progress something like the following error occurred: "unable to save the page...". on the other hand, once, I saved a web page successfully, but when I opened it the characters were completely unreadable. unfortunately I can't remember the url now but if you know any way to restrict users,
5
1334
by: TC | last post by:
I don't use the Form Designer. Is there any way to disable it completely? I find it annoying that every time I create a new form, or double-click on an existing one, Visual Studio uses the Designer by default. It would be nice if I could turn that off. -TC
0
9656
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10386
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10182
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10131
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9973
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9003
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5542
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4081
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2899
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.