Results 1 to 7 of 7

Thread: Error message Using External .JS files

  1. #1
    Join Date
    Apr 2010
    Posts
    6
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default Error message Using External .JS files

    Hello everyone !!! This is the problem I'm having:

    I'm trying to incorporate a Right-Click-Disable script into my webpage by using an external .js file since I have several pages in my website. The thing is that when I run it I get an INVALID CHARACTER error pointing to Line 1 Character 1 of the .js file and I just can't seem to find the error. Here are the HTML and .js files I'm using (in an empty webpage to run as test) :
    -----------------------
    THE HTML FILE:

    <html>
    <head>
    <script type="text/javascript" src="disablemouse.js">
    </script>

    </head>

    <body>
    </body>
    <p>

    <body>
    </body>
    </html>

    -------------------------
    THIS IS THE disablemouse.js FILE:

    <!--
    //Disable right click script III- By Renigade(renigade@mediaone.net)
    //For full source code, visit http://www.dynamicdrive.com
    var message="";
    ///////////////////////////////////
    function clickIE() {if (document.all) {(message);return
    false;}}
    function clickNS(e) {if
    (document.layers||(document.getElementById&&!document.all))
    {
    if (e.which==2||e.which==3) {(message);return false;}}}
    if (document.layers)
    {document.captureEvents(Event.MOUSEDOWN);document.onmousedown=clickNS;}
    else{document.onmouseup=clickNS;document.oncontextmenu=clickIE;}
    document.oncontextmenu=new Function("return false")
    // -->

    -------------------------

    I'm using Front page as my webpage editor. When I run it without the .js file it works perfect, the problem comes when I use the external file approach.

    Thanks.

  2. #2
    Join Date
    Apr 2010
    Posts
    6
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default

    sos - anybody please!!!!
    Read previous posting.

    Thanks

  3. #3
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,164
    Thanks
    265
    Thanked 690 Times in 678 Posts

    Default

    Allow more than 2 hours to pass. There's no point in bumping the thread so early. Someone will help you when they have a chance. Also, unanswered threads are more likely to get responses, so posting more will run the risk of having users think the question is already answered if there are replies.
    Daniel - Freelance Web Design | <?php?> | <html>| español | Deutsch | italiano | português | català | un peu de français | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum

  4. The Following User Says Thank You to djr33 For This Useful Post:

    java55 (04-13-2010)

  5. #4
    Join Date
    Jan 2008
    Posts
    4,168
    Thanks
    28
    Thanked 628 Times in 624 Posts
    Blog Entries
    1

    Default

    Djr33 - I'd say 24 hours... Try deleting the <!-- and // -->
    Jeremy | jfein.net

  6. #5
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,164
    Thanks
    265
    Thanked 690 Times in 678 Posts

    Default

    Yes, to be clear-- I meant that bumping WITHIN 2 hours is very bad. Waiting 24 (at least) is normal/good.
    Daniel - Freelance Web Design | <?php?> | <html>| español | Deutsch | italiano | português | català | un peu de français | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum

  7. #6
    Join Date
    Apr 2010
    Posts
    6
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default

    Thanks, I tried that too and nothing happens.

  8. #7
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,164
    Thanks
    265
    Thanked 690 Times in 678 Posts

    Default

    The .js file should look like this:
    Code:
    //Disable right click script III- By Renigade(renigade@mediaone.net)
    //For full source code, visit http://www.dynamicdrive.com
    var message="";
    ///////////////////////////////////
    function clickIE() {if (document.all) {(message);return
    false;}}
    function clickNS(e) {if
    (document.layers||(document.getElementById&&!document.all))
    {
    if (e.which==2||e.which==3) {(message);return false;}}}
    if (document.layers)
    {document.captureEvents(Event.MOUSEDOWN);document.onmousedown=clickNS;}
    else{document.onmouseup=clickNS;document.oncontextmenu=clickIE;}
    document.oncontextmenu=new Function("return false")
    (as Nile suggested).
    If it still doesn't work, then post a link to your page so we can see what's wrong. With just the code it's hard to tell what is not correct.



    Also, this script is basically useless. More importantly, it's annoying. There is no case where you can actually stop people from doing things on the website (like saving images, viewing the source code, etc), so adding this will just annoy people because it will stop them from doing normal things (like right click > bookmark this page, or right click > open link in new window). You can use it if you want, but usually it's a mistake.

    The only times when this is actually useful is when you want to do something ELSE when you right click, such as adding a custom right click menu for a web-app. But even then there are problems with compatibility, etc.
    Daniel - Freelance Web Design | <?php?> | <html>| español | Deutsch | italiano | português | català | un peu de français | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum

Bookmarks

Posting Permissions

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