SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Enthusiast
    Join Date
    Dec 2004
    Location
    Richmond
    Posts
    40
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Hide javascript from downloaded pages?

    Hello all. Does anyone know of a handy way to disable a user from downloading javascript when they save a page?

    Here is my problem. I have javascript that disables right clicks on a page. However the user could just "save" the page to there desktop and remove the function that disables right clicks.

    Anyone know of a good work around? I've heard of other complex ways, but I was looking for a simple solution.

    Thanks in advance!

  2. #2
    SitePoint Wizard
    Join Date
    Nov 2004
    Location
    Nelson BC
    Posts
    2,310
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    mmm - I think there's always a hack for anti-right-click scripts - it depends on what you are trying to hide.

    If you don't want them seeing the javascript, the best I can think of (which is complex too) is put your external javascript file into a ASP/PHP file and check that the referer is in your domain before writing it out. Something like

    myjs.asp
    Code:
    <%
    Response.CacheControl="No-cache"
    myDomain = "mydomain.com"
    If InStr(1, Request.ServerVariables("HTTP_Referer"), myDomain) > 0 Then
    %>
    //Real Javascript
    function real() {
    	alert("hi");
    }
    <%
    Else
    %>
    //Access Denied
    <%
    End If
    %>
    Then attach it to your html with:
    <script language="javascript" src="myjs.asp"></script>

    It can never work 100% though.

  3. #3
    Non-Member
    Join Date
    Jan 2005
    Location
    Netherlands
    Posts
    4,300
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hello

    Give me the url web address to your site I want it, I need it, this Rocket Launching gold dust wasting JavaScript

  4. #4
    SitePoint Enthusiast
    Join Date
    Dec 2004
    Location
    Richmond
    Posts
    40
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hey Jim. Thanks for the reply. I'm trying to hide the function that disables the right click. If I could hide it, then the user couldn't download the site, then remove that function.

    I've talk to another developer that gave me a way to store information in the users session, then if the user request the page for download, it would store the javascript in cache and not output it to the page, but that seemed overly complicated, plus it involved a great deal of other coding. I was hoping that someone might have a simpler solution.

  5. #5
    SitePoint Wizard
    Join Date
    Nov 2004
    Location
    Nelson BC
    Posts
    2,310
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Nick,

    It does seem like a lot of work, and there are ways to disable right-click catchers that will render any tricks you try useless.

    Google -> favelet right click

    (there is no defense, except for extreme use of setTimeout)


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
  •