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

M

Michael

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
 
V

VK

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:/NameOfDirectoryWithYourHTMLtemplates/

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.images.length;i++) {
if (document.images.src.indexOf('%') != -1) {
self.location.href = yourServerScriptURL;
}
}
}

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

Grant Wagner

Michael said:
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

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.images && (i = document.images.length)) {
while (i-- > 0) {
if (document.images.src.indexOf('%filename%.jpg') != -1) {
window.location.href = 'somewhereElse.html';
}
}
}
}
</script>
<img src="%filename%.jpg">
 
M

Michael

VK said:
2.
For now on your pages with %images% you may use a script like that:
function checkImages() {
for (i=0;document.images.length;i++) {
if (document.images.src.indexOf('%') != -1) {
self.location.href = yourServerScriptURL;
}
}
}
and:
<body onLoad="checkImages()">
<noscript>
<h3>A few encouraging words to whom JavaScript is disallowed</h3>
</noscript>
....



Thank you very much... That did it!

Mike
 
M

Michael

VK said:
For now on your pages with %images% you may use a script like that:
function checkImages() {
for (i=0;document.images.length;i++) {
if (document.images.src.indexOf('%') != -1) {
self.location.href = yourServerScriptURL;
}
}
}
and:
<body onLoad="checkImages()">

Thank you very much... That did it!
Mike


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

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

Mike
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,754
Messages
2,569,527
Members
45,000
Latest member
MurrayKeync

Latest Threads

Top