943,913 Members | Top Members by Rank

Ad:
You are currently viewing page 1 of this multi-page discussion thread
Apr 10th, 2008
0

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

Expand Post »
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.
Reputation Points: 10
Solved Threads: 0
Junior Poster in Training
vedmack is offline Offline
59 posts
since Feb 2008
Apr 10th, 2008
0

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

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 .
Super Moderator
Featured Poster
Reputation Points: 3233
Solved Threads: 719
Failure as a human
~s.o.s~ is offline Offline
8,871 posts
since Jun 2006
Apr 12th, 2008
0

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

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!
Reputation Points: 730
Solved Threads: 181
Nearly a Senior Poster
MidiMagic is offline Offline
3,314 posts
since Jan 2007
Apr 13th, 2008
0

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

Click to Expand / Collapse  Quote originally posted by MidiMagic ...
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.
Reputation Points: 10
Solved Threads: 0
Junior Poster in Training
vedmack is offline Offline
59 posts
since Feb 2008
Apr 13th, 2008
0

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

Click to Expand / Collapse  Quote originally posted by ~s.o.s~ ...
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?
Reputation Points: 10
Solved Threads: 0
Junior Poster in Training
vedmack is offline Offline
59 posts
since Feb 2008
Apr 14th, 2008
0

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

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.
Reputation Points: 730
Solved Threads: 181
Nearly a Senior Poster
MidiMagic is offline Offline
3,314 posts
since Jan 2007
Apr 15th, 2008
0

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

Click to Expand / Collapse  Quote originally posted by MidiMagic ...
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?
Reputation Points: 10
Solved Threads: 0
Junior Poster in Training
vedmack is offline Offline
59 posts
since Feb 2008
Apr 15th, 2008
0

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

Click to Expand / Collapse  Quote originally posted by vedmack ...
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.
Reputation Points: 23
Solved Threads: 16
Posting Whiz in Training
plazmo is offline Offline
206 posts
since Aug 2005
Apr 15th, 2008
0

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

Click to Expand / Collapse  Quote originally posted by plazmo ...
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...
Reputation Points: 10
Solved Threads: 0
Junior Poster in Training
vedmack is offline Offline
59 posts
since Feb 2008
Apr 15th, 2008
0

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

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.
Super Moderator
Featured Poster
Reputation Points: 3233
Solved Threads: 719
Failure as a human
~s.o.s~ is offline Offline
8,871 posts
since Jun 2006

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in JavaScript / DHTML / AJAX Forum Timeline: Editing client side registry
Next Thread in JavaScript / DHTML / AJAX Forum Timeline: Displaying all object properties





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC