Register

If this is your first visit, please click the Sign Up now button to begin the process of creating your account so you can begin posting on our forums! The Sign Up process will only take up about a minute of two of your time.

Results 1 to 6 of 6
  1. #1
    Junior Member
    Join Date
    Aug 2008
    Posts
    2
    Member #
    17270
    I'm new and I need help with getting a script that protects images from being copied by disabling the right click context menu, drag and drop and selecting text, to validate in xhtml. Here's the oneline script:
    <body oncontextmenu="return false" ondragstart="return false" onselectstart="return false">
    The 3 errors I get are:
    there is no attribute "oncontextmenu".
    there is no attribute "ondragstart".
    there is no attribute "onselectstart".
    Does anyone know how to make it validate in xhtml ?


  2.  

  3. #2
    Senior Member
    Join Date
    May 2003
    Location
    UK
    Posts
    2,354
    Member #
    1326
    You cannot have JS events in the body tag, so just declare them in JS code.

    HTML Code:
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
    
    <head>
    
    	<meta http-equiv="content-type" content="text/html;charset=utf-8" />
    
    	<title>Valid XHTML with JS</title>
    
    	<script type="text/javascript">
    
    		document.oncontextmenu = function() { return false; }
    		document.ondragstart = function() { return false; }
    		document.onselectstart = function() { return false; }
    
    	</script>
    
    </head>
    
    <body>
    
    </body>
    </html>
    Tried and tested.

  4. #3
    Junior Member
    Join Date
    Aug 2008
    Posts
    2
    Member #
    17270
    Thanks alot for your help, I just included the:
    document.oncontextmenu = function() { return false; }
    document.ondragstart = function() { return false; }
    document.onselectstart = function() { return false; }

    in my imageviewer.js and it works like a charm
    Thanks again

  5. #4
    Senior Member
    Join Date
    Apr 2005
    Location
    Hatfield, England
    Posts
    855
    Member #
    9790
    Could I ask. What stops someone from using the 'print screen' button?

  6. #5
    Senior Member
    Join Date
    May 2003
    Location
    UK
    Posts
    2,354
    Member #
    1326
    Guess: document.onkeydown. LOL, lets block all user interactivity!

  7. #6
    WDF Staff smoseley's Avatar
    Join Date
    Mar 2003
    Location
    Boston, MA
    Posts
    9,729
    Member #
    819
    Liked
    205 times
    Code:
    document.onprintscreen = function { kill(user) };
    
    function kill(whoToKill) {
       whoToKill = null;
    }
    :-D


Remove Ads

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

Search tags for this page

there is no attribute ondragstart

Click on a term to search for related topics.
All times are GMT -6. The time now is 05:21 AM.
Powered by vBulletin® Version 4.2.3
Copyright © 2019 vBulletin Solutions, Inc. All rights reserved.
vBulletin Skin By: PurevB.com