%filename% passed as cgi variable how do I...

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Michael

    %filename% passed as cgi variable how do I...


    All,

    I'll asked a question but I was not detailed (clear) enough for people to
    help so I'll retry.

    I have a cgi script pass a variable from one page to the next. The
    'receiving' page replaces this variable (in this case %filename%) with
    whatever was passed.

    This works fine when the page is called from the cgi script because it has
    passed %filename%.

    But when the page is found from a search engine the page looks like this:

    --------------------------------------------------
    The picture below is %filename%.

    To get a copy printed please e-mail us.

    Thank you.

    -----
    | |
    | |
    -----
    --------------------------------------------------
    (the box above just shows a place holder for a image because the %filename%
    would not be passed if this page was found by a search engine)
    The html source of the page has: <img src="%filename% .jpg">
    But when called from the CGI program it would read <img src="London.jpg ">
    (or any other name passed by the cgi program.)


    So to the question... Is there any way in JavaScript to see if either
    %filename% exists on the page still (when the cgi program calls this page it
    will always replace every occurrence of %filename% so the page would only
    have %filename% on the page if called directly or if found from a search
    engine) OR any other method to redirect the page to another one if
    %filename% is not passed from the CGI program?

    Thank you,

    Mike


  • VK

    #2
    Re: %filename% passed as cgi variable how do I...

    1.
    I would suggest after reading this message do the follow:

    a) create a text file named robots.txt

    b) add two lines to this file:
    User-agent:*
    Disallow:/NameOfDirectory WithYourHTMLtem plates/

    c) save the file and place it in the root directory of your server

    This will not undo damages already made, but at least webbots will stop
    indexing your %images% templates.
    (I assume these templates are NOT in the root directory and the are NOT the
    very same pages you indeed willing to have in the search index).


    2.
    For now on your pages with %images% you may use a script like that:

    function checkImages() {
    for (i=0;document.i mages.length;i+ +) {
    if (document.image s[i].src.indexOf('% ') != -1) {
    self.location.h ref = yourServerScrip tURL;
    }
    }
    }

    and:
    ....
    <body onLoad="checkIm ages()">
    <noscript>
    <h3>A few encouraging words to whom JavaScript is disallowed</h3>
    </noscript>
    .....




    Comment

    • Grant Wagner

      #3
      Re: %filename% passed as cgi variable how do I...

      Michael wrote:
      [color=blue]
      > All,
      >
      > I'll asked a question but I was not detailed (clear) enough for people to
      > help so I'll retry.
      >
      > I have a cgi script pass a variable from one page to the next. The
      > 'receiving' page replaces this variable (in this case %filename%) with
      > whatever was passed.
      >
      > This works fine when the page is called from the cgi script because it has
      > passed %filename%.
      >
      > But when the page is found from a search engine the page looks like this:
      >
      > --------------------------------------------------
      > The picture below is %filename%.
      >
      > To get a copy printed please e-mail us.
      >
      > Thank you.
      >
      > -----
      > | |
      > | |
      > -----
      > --------------------------------------------------
      > (the box above just shows a place holder for a image because the %filename%
      > would not be passed if this page was found by a search engine)
      > The html source of the page has: <img src="%filename% .jpg">
      > But when called from the CGI program it would read <img src="London.jpg ">
      > (or any other name passed by the cgi program.)
      >
      > So to the question... Is there any way in JavaScript to see if either
      > %filename% exists on the page still (when the cgi program calls this page it
      > will always replace every occurrence of %filename% so the page would only
      > have %filename% on the page if called directly or if found from a search
      > engine) OR any other method to redirect the page to another one if
      > %filename% is not passed from the CGI program?
      >
      > Thank you,
      >
      > Mike[/color]

      Your explanation still isn't clear enough, but it seems that you are wondering
      if client-side JavaScript could determine whether any image on a page is called
      %filename%.jpg and redirect based on that? The answer to that is: yes.

      <script type="text/javascript">
      window.onload = function() {
      var i;
      if (document.image s && (i = document.images .length)) {
      while (i-- > 0) {
      if (document.image s[i].src.indexOf('% filename%.jpg') != -1) {
      window.location .href = 'somewhereElse. html';
      }
      }
      }
      }
      </script>
      <img src="%filename% .jpg">

      --
      Grant Wagner <gwagner@agrico reunited.com>
      comp.lang.javas cript FAQ - http://jibbering.com/faq

      Comment

      • Michael

        #4
        Re: %filename% passed as cgi variable how do I...


        "VK" <schools_ring@y ahoo.com> wrote in message
        news:41766570$0 $190$9b622d9e@n ews.freenet.de. ..[color=blue]
        > 2.
        > For now on your pages with %images% you may use a script like that:
        > function checkImages() {
        > for (i=0;document.i mages.length;i+ +) {
        > if (document.image s[i].src.indexOf('% ') != -1) {
        > self.location.h ref = yourServerScrip tURL;
        > }
        > }
        > }
        > and:
        > <body onLoad="checkIm ages()">
        > <noscript>
        > <h3>A few encouraging words to whom JavaScript is disallowed</h3>
        > </noscript>
        > ....[/color]


        Thank you very much... That did it!

        Mike


        Comment

        • Michael

          #5
          Re: %filename% passed as cgi variable how do I...

          > "VK" <schools_ring@y ahoo.com> wrote in message[color=blue][color=green]
          > > For now on your pages with %images% you may use a script like that:
          > > function checkImages() {
          > > for (i=0;document.i mages.length;i+ +) {
          > > if (document.image s[i].src.indexOf('% ') != -1) {
          > > self.location.h ref = yourServerScrip tURL;
          > > }
          > > }
          > > }
          > > and:
          > > <body onLoad="checkIm ages()">[/color]
          > Thank you very much... That did it!
          > Mike[/color]

          Actually I adjusted it a bit because I only needed to check one image.

          <script type="text/javascript">
          function checkImages() {
          if (document.image s[0].src.indexOf('% ') != -1) {
          top.location.hr ef = 'http://www.tomsphotos. com/index.htm';
          }
          }
          </script>

          Mike


          Comment

          Working...