How to apply No right click script inhere...?

Please support our JavaScript / DHTML / AJAX advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
Reply

Join Date: Feb 2008
Posts: 51
Reputation: vedmack is an unknown quantity at this point 
Solved Threads: 0
vedmack vedmack is offline Offline
Junior Poster in Training

How to apply No right click script inhere...?

 
0
  #1
Apr 10th, 2008
Hi
I built a html page with a single button which suppose to open new window which shows XML file...

I want to disable right click mouse in the "new window" which is being opened after button hit...

I do know how to disable the right click inside an ordinary html page : "<body oncontextmenu="return false;">"

but how can i do it in the new opened window... i tryed several ways but without luck
:/

here is the code:

JavaScript / DHTML / AJAX Syntax (Toggle Plain Text)
  1. <html>
  2. <body oncontextmenu="return false;">
  3. <script language="javascript" type="text/javascript">
  4. function showExternalXml(){
  5. w=800
  6. h=800
  7.  
  8. l=200
  9. t=200
  10. globalHTML="<html><head><title>name.xml</title></head><frameset rows='100%'><frame src='c:\\dir\\name.xml'></frame></frameset></html>";
  11. window.open("javascript:opener.globalHTML",'HeavyXml',',resizable=1,width='+w+',height='+h+',left='+l+',top='+t+'');
  12. }
  13. </script>
  14. <table border="1" style="cursor: pointer ">
  15. <tr>
  16. <td bgcolor=#CCCCCC>
  17. <input type="button" value="Display Xml" onclick="showExternalXml() "style="cursor: pointer "> </input>
  18. </td>
  19. </tr>
  20. </table>
  21. </body>
  22. </html>


Thanks ahead.

Daniel.
Last edited by vedmack; Apr 10th, 2008 at 9:46 am.
Reply With Quote Quick reply to this message  
Join Date: Jun 2006
Posts: 7,623
Reputation: ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of 
Solved Threads: 468
Super Moderator
Featured Poster
~s.o.s~'s Avatar
~s.o.s~ ~s.o.s~ is offline Offline
Failure as a human

Re: How to apply No right click script inhere...?

 
0
  #2
Apr 10th, 2008
AFAIK, the oncontextmenu is not supported across all browsers. But still if you want that kind of functionality, create a new HTML page which would be popped to the user when he clicks on the link. Inside that page instead of loading the XML document in a frame, load it in an iframe . That way you can have a body element inside your newly created page which can have the attribute oncontextmenu set as false .
I don't accept change; I don't deserve to live.
Reply With Quote Quick reply to this message  
Join Date: Jan 2007
Posts: 3,210
Reputation: MidiMagic has a spectacular aura about MidiMagic has a spectacular aura about 
Solved Threads: 165
MidiMagic's Avatar
MidiMagic MidiMagic is offline Offline
Nearly a Senior Poster

Re: How to apply No right click script inhere...?

 
0
  #3
Apr 12th, 2008
Stop trying to take over the user's computer.

It belongs to that user, NOT TO YOU!

If you want to protect your pages from things the user can do, then DON'T PUBLISH THEM ON THE INTERNET!
Daylight-saving time uses more gasoline
Reply With Quote Quick reply to this message  
Join Date: Feb 2008
Posts: 51
Reputation: vedmack is an unknown quantity at this point 
Solved Threads: 0
vedmack vedmack is offline Offline
Junior Poster in Training

Re: How to apply No right click script inhere...?

 
0
  #4
Apr 13th, 2008
Originally Posted by MidiMagic View Post
Stop trying to take over the user's computer.

It belongs to that user, NOT TO YOU!

If you want to protect your pages from things the user can do, then DON'T PUBLISH THEM ON THE INTERNET!


Listen...

All I want to do it to prevent the user from accessing to the source of an XML files I'm showing to the user... I don't want to revile the user the info of where the xml is locked on the network... (view source on xml opens it in notepad which by clicking "save as" gives the full path of the xml file to the user...)

thats all....

Relax... its all gonna be alright....
Last edited by vedmack; Apr 13th, 2008 at 1:21 am.
Reply With Quote Quick reply to this message  
Join Date: Feb 2008
Posts: 51
Reputation: vedmack is an unknown quantity at this point 
Solved Threads: 0
vedmack vedmack is offline Offline
Junior Poster in Training

Re: How to apply No right click script inhere...?

 
0
  #5
Apr 13th, 2008
Originally Posted by ~s.o.s~ View Post
AFAIK, the oncontextmenu is not supported across all browsers. But still if you want that kind of functionality, create a new HTML page which would be popped to the user when he clicks on the link. Inside that page instead of loading the XML document in a frame, load it in an iframe . That way you can have a body element inside your newly created page which can have the attribute oncontextmenu set as false .


I tried ~s.o.s~ suggest...

Here:

JavaScript / DHTML / AJAX Syntax (Toggle Plain Text)
  1. <html>
  2. <body oncontextmenu="return false;">
  3. <iframe src='c:\name.xml'>
  4.  
  5. </iframe>
  6. </body>
  7. </html>

but the no right click does not affect the iframe... I still can press right click inside the iframe...

any other ideas?
Reply With Quote Quick reply to this message  
Join Date: Jan 2007
Posts: 3,210
Reputation: MidiMagic has a spectacular aura about MidiMagic has a spectacular aura about 
Solved Threads: 165
MidiMagic's Avatar
MidiMagic MidiMagic is offline Offline
Nearly a Senior Poster

Re: How to apply No right click script inhere...?

 
0
  #6
Apr 14th, 2008
That's because the right click is part of windows, not your web page.

You don't have the right to prevent it. It belongs to the owner of the computer.

What could possibly be in the XML content of a file that you want to hide?

If you are afraid that someone will steal a programming technique you devised, then put a notice in that programming.

If the user is viewing the rendered file, the file is on the user's computer disk already. He can get it with My Computer using the start button, and you can't do anything to prevent that.
Daylight-saving time uses more gasoline
Reply With Quote Quick reply to this message  
Join Date: Feb 2008
Posts: 51
Reputation: vedmack is an unknown quantity at this point 
Solved Threads: 0
vedmack vedmack is offline Offline
Junior Poster in Training

Re: How to apply No right click script inhere...?

 
0
  #7
Apr 15th, 2008
Originally Posted by MidiMagic View Post
That's because the right click is part of windows, not your web page.

You don't have the right to prevent it. It belongs to the owner of the computer.

What could possibly be in the XML content of a file that you want to hide?

If you are afraid that someone will steal a programming technique you devised, then put a notice in that programming.

If the user is viewing the rendered file, the file is on the user's computer disk already. He can get it with My Computer using the start button, and you can't do anything to prevent that.
Listen...its a web application that im doing... not some "fun portal"....so no users will be ticked....

All i wanna do is somehow hide the full path of the presented xml that are actually stored on some network drive...

Any ideas ono how to do it?
Reply With Quote Quick reply to this message  
Join Date: Aug 2005
Posts: 206
Reputation: plazmo is an unknown quantity at this point 
Solved Threads: 16
plazmo's Avatar
plazmo plazmo is offline Offline
Posting Whiz in Training

Re: How to apply No right click script inhere...?

 
0
  #8
Apr 15th, 2008
Originally Posted by vedmack View Post
I tried ~s.o.s~ suggest...

JavaScript / DHTML / AJAX Syntax (Toggle Plain Text)
  1. <html>
  2. <body oncontextmenu="return false;">
  3. <iframe src='c:\name.xml'>
  4.  
  5. </iframe>
  6. </body>
  7. </html>

First off you cannot link to c:\
Unless name.xml is on every users computer nothing will show there.

Saving the file does not reveal the files location, its probably just that you have the src wrong.

Lastly, its not possible to completely block the rightclick.
Reply With Quote Quick reply to this message  
Join Date: Feb 2008
Posts: 51
Reputation: vedmack is an unknown quantity at this point 
Solved Threads: 0
vedmack vedmack is offline Offline
Junior Poster in Training

Re: How to apply No right click script inhere...?

 
0
  #9
Apr 15th, 2008
Originally Posted by plazmo View Post
First off you cannot link to c:\
Unless name.xml is on every users computer nothing will show there.

Saving the file does not reveal the files location, its probably just that you have the src wrong.

Lastly, its not possible to completely block the rightclick.

1) actually its on a network drive.... (c: was just an example)

2)when file is being viewed with internet explorer it is possible to right click and choose "view source" on xml which opens it in notepad and by by clicking "file->save as" gives the full path of the xml file to the user...(z:\foldername\name.xml) <-- i wanna hide this path...

3)its an webapplication.. not some simple website...
Reply With Quote Quick reply to this message  
Join Date: Jun 2006
Posts: 7,623
Reputation: ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of 
Solved Threads: 468
Super Moderator
Featured Poster
~s.o.s~'s Avatar
~s.o.s~ ~s.o.s~ is offline Offline
Failure as a human

Re: How to apply No right click script inhere...?

 
0
  #10
Apr 15th, 2008
The best, safest and the most appropriate solution in this case would be to implement the functionality in the server side language of your choice.
I don't accept change; I don't deserve to live.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Other Threads in the JavaScript / DHTML / AJAX Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC