Results 1 to 12 of 12
  1. #1
    2 Star Lounger
    Join Date
    Feb 2001
    Location
    Chicago, Illinois, USA
    Posts
    177
    Thanks
    0
    Thanked 0 Times in 0 Posts

    No right-click for photos loaded in frames

    I know how to stop no right-clicks (to copy a photo) on a normal page:

    <script language="Javascript1.2">
    message = "Contact us for a copy of any photo";
    function NoRightClick([img]/forums/images/smilies/cool.gif[/img] {
    if(((navigator.appName=="Microsoft Internet Explorer")&&(event.button > 1))
    ||((navigator.appName=="Netscape")&&(b.which > 1))){
    alert(message);
    return false;
    }
    }
    document.onmousedown = NoRightClick;

    // -->
    </script>

    But when I load a photo in one of the frames (the main "content" frame) the blocking no longer works. ??? I don't know a way around this, other than to put each photo on its own HTML page (not worth it!). Any ideas?

    If you want to see what I mean:

    1. go to my site at www.spanitz.com
    2. click on the "photos" menu option at the top
    3. go into the gallery

    Note that the first photo is blocked from copying, but as soon as you load any other image from the menu on the left, the blocking is no longer in effect.

    This is not a huge deal (I'm not the greatest photographer, and if somebody wants a photo they can have it...I guess I'd just like to have some sense of who likes what photos?) -- just wondering if it can be done.
    <font color=blue>Eric A. Spanitz</font color=blue>
    Quality, Project, Management * Training * Consulting
    http://www.spanitz.com * http://www.synergest.com

  2. #2
    Silver Lounger
    Join Date
    Jan 2001
    Location
    Indianapolis, Indiana, USA
    Posts
    1,862
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: No right-click for photos loaded in frames

    Hi Eric,

    You can easily fix this by using a server-side page to load the pictures. I use ASP/ASP.NET, and I'll offer a quick example in that context. If your web host is *nix (unix or Linux), you'll need to use another supported language (CGI/PERL or PHP).

    Create a web page for your photos (named photos.asp) with the following content:<pre><%@Page Language="vbscript" %>
    <%
    Dim strPhoto
    strPhoto = Request.Querystring("p")
    %>
    <html>
    <head>
    <script>....Put your javascript here</script>
    </head>
    <body>
    [img]<%=strPhoto%>[/img]
    </body>
    </html></pre>

    The only other thing to do is update the links for your photos to the following format:
    Your Link

    Hope this helps!

  3. #3
    Super Moderator jscher2000's Avatar
    Join Date
    Feb 2001
    Location
    Silicon Valley, USA
    Posts
    23,112
    Thanks
    5
    Thanked 93 Times in 89 Posts

    Re: No right-click for photos loaded in frames

    I think it is because there is no HTML page in that frame.

    In addition to Mark's server side solution, you can do a very similar thing on the client side with JavaScript. I've posted the code before, but can't search for it now. In general, in JavaScript you get a parameter from the end of the URL like this:

    URL => pframe.html?img0001.jpg

    JS => location.search => ?img0001.jpg

    Now you need to get rid of the ? using a string function

    Then you use document.write to insert that file name into the file.

    Can whoever I helped with this before please please post the code?

  4. #4
    2 Star Lounger
    Join Date
    Feb 2001
    Location
    Chicago, Illinois, USA
    Posts
    177
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: No right-click for photos loaded in frames

    This sounds good, but this went over my head.

    Am I reading your suggestion as: in the "link" (HTML code for the photo) I do not just have the photo file referenced, I also include some javascript in with the link itself? I haven't done that before...
    <font color=blue>Eric A. Spanitz</font color=blue>
    Quality, Project, Management * Training * Consulting
    http://www.spanitz.com * http://www.synergest.com

  5. #5
    2 Star Lounger
    Join Date
    Feb 2001
    Location
    Chicago, Illinois, USA
    Posts
    177
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: No right-click for photos loaded in frames

    *laugh* I don't know if I agree with your inclusion of "easily" in that reply... Thanks. I know I have to use PERL / CGI on this host. This at least gives me something to muddle around with. Thanks again.
    <font color=blue>Eric A. Spanitz</font color=blue>
    Quality, Project, Management * Training * Consulting
    http://www.spanitz.com * http://www.synergest.com

  6. #6
    2 Star Lounger
    Join Date
    Feb 2001
    Location
    Chicago, Illinois, USA
    Posts
    177
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: No right-click for photos loaded in frames

    Okay, I'm stuck.

    I have a PERL CGI (yes, the PERL directory is correctly specified at the top <grin>.):

    --------------------------------------------------------------
    #!/usr/local/bin/perl

    # Change this to the PATH (not the URL) of the head.txt file
    # (include the filename)

    $headfile = '/photoh.txt';

    # Change this to the PATH (not the URL) of the foot.txt file
    # (include the filename)

    $footfile = '/photof.txt';

    $File = $ENV{'QUERY_STRING'};

    # Get the heading information

    unless (open (DATA,"$headfile")) {die (&error);}
    if ($uselock eq '1') {
    flock DATA, 2;
    seek DATA, 0, 0;
    }
    @headinfo = <DATA>;
    if ($uselock eq '1') {
    flock DATA, 8;
    }
    close (DATA);
    foreach $headline (@headinfo){
    $heading = $heading.$headline;
    }

    # Get the footer information

    unless (open (DATA,"$footfile")) {die (&error);}
    if ($uselock eq '1') {
    flock DATA, 2;
    seek DATA, 0, 0;
    }
    @footinfo = <DATA>;
    if ($uselock eq '1') {
    flock DATA, 8;
    }
    close (DATA);
    foreach $footline (@footinfo){
    $footer = $footer.$footline;
    }

    ################# MAIN PROGRAM ######################

    print "Content-type:text/htmlnn";
    print "$heading";
    print "[img]$File[/img]";
    print "$footer";
    --------------------------------------------------------------

    The header file:

    --------------------------------------------------------------
    <html>
    <body bgcolor=#FFFFFF>
    <script language="Javascript1.2">
    message = "Contact us at 888.772.6489 for a copy of any photo";
    function NoRightClick([img]/forums/images/smilies/cool.gif[/img] {
    if(((navigator.appName=="Microsoft Internet Explorer")&&(event.button > 1))
    ||((navigator.appName=="Netscape")&&(b.which > 1))){
    alert(message);
    return false;
    }
    }
    document.onmousedown = NoRightClick;

    // -->
    </script>
    --------------------------------------------------------------


    The footer file is pretty much empty:

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

    </html>
    --------------------------------------------------------------


    And the link in the menu is:

    Lake Tahoe Storm 3


    I get a "Server Error". And contacting the Administrator (that'd be me) isn't going to help me... <grin>

    Any ideas? I am continuing to repeat to myself: "this is a wonderful learning opportunity..."
    <font color=blue>Eric A. Spanitz</font color=blue>
    Quality, Project, Management * Training * Consulting
    http://www.spanitz.com * http://www.synergest.com

  7. #7
    Super Moderator jscher2000's Avatar
    Join Date
    Feb 2001
    Location
    Silicon Valley, USA
    Posts
    23,112
    Thanks
    5
    Thanked 93 Times in 89 Posts

    Re: No right-click for photos loaded in frames

    No, you don't have to put code into a URL. Here's the code for a page to hold the photo, call it, say, imgframe.html:

    <html>
    <head>
    <title>Image Frame</title>
    <BASE HREF="http://www.spanitz.com/">
    </head>
    <body>
    <script language="JavaScript">
    var strHREF = location.search;
    if (strHREF == "") {
    strHREF = "?/images/n100.jpg";
    }
    document.write("[img][/img]");
    </script>
    </body>
    </html>

    Note that the BASE tag is in there for testing, and the "default" image file name is up to you.

    You then would change your navigation pane's links to something like:

    description
    description
    description

    So.... does this solve the original problem?

  8. #8
    2 Star Lounger
    Join Date
    Feb 2001
    Location
    Chicago, Illinois, USA
    Posts
    177
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: No right-click for photos loaded in frames

    Perfect!

    That stupid CGI stuff was maddening.

    This is so much easier. And I learned the ? variable passing to an HTML and even setting up a default. Thank you very much!!!
    <font color=blue>Eric A. Spanitz</font color=blue>
    Quality, Project, Management * Training * Consulting
    http://www.spanitz.com * http://www.synergest.com

  9. #9
    Super Moderator jscher2000's Avatar
    Join Date
    Feb 2001
    Location
    Silicon Valley, USA
    Posts
    23,112
    Thanks
    5
    Thanked 93 Times in 89 Posts

    Re: No right-click for photos loaded in frames

    I see it works. Or should I say, I see that I can't right-click the page and confirm that it's my source code. <img src=/S/grin.gif border=0 alt=grin width=15 height=15>

    (Okay, actually I did figure out a way to inspect the code for that frame. Click in the address bar, press Shift+Tab, then the "right-click key" on the keyboard, then View Source. But the image can't be saved this way, as far as I can tell.)

  10. #10
    2 Star Lounger
    Join Date
    Feb 2001
    Location
    Chicago, Illinois, USA
    Posts
    177
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: No right-click for photos loaded in frames

    Yes it works. Thank you!! I know that there are some methods for getting around it, but at least I want to have a little more control over the stuff. And people can always ask for me to e-mail them the photos.

    Thanks again. This was one of those annoying things that I figured there was some way to deal with, but I didn't know how.
    <font color=blue>Eric A. Spanitz</font color=blue>
    Quality, Project, Management * Training * Consulting
    http://www.spanitz.com * http://www.synergest.com

  11. #11
    Plutonium Lounger
    Join Date
    Nov 2001
    Posts
    10,550
    Thanks
    0
    Thanked 7 Times in 7 Posts

    Re: No right-click for photos loaded in frames

    When you see the source it is easy to just point your browser at http://www.spanitz.com/bgimage.jpg

    StuartR

  12. #12
    2 Star Lounger
    Join Date
    Feb 2001
    Location
    Chicago, Illinois, USA
    Posts
    177
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: No right-click for photos loaded in frames

    Oh I know... It isn't like I have $100,000 NASA photos posted. <grin> You and I know there are also several other simple (and some automatic) ways to nab photos. My question was more for my own knowledge... knowing that there has to be some way to do it (load photos in a frame yet keep some javascript also loading with them).
    <font color=blue>Eric A. Spanitz</font color=blue>
    Quality, Project, Management * Training * Consulting
    http://www.spanitz.com * http://www.synergest.com

Posting Permissions

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