473,386 Members | 1,705 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

%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
Jul 23 '05 #1
4 1882
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[i].src.indexOf('%') != -1) {
self.location.href = yourServerScriptURL;
}
}
}

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


Jul 23 '05 #2
Michael wrote:
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[i].src.indexOf('%filename%.jpg') != -1) {
window.location.href = 'somewhereElse.html';
}
}
}
}
</script>
<img src="%filename%.jpg">

--
Grant Wagner <gw*****@agricoreunited.com>
comp.lang.javascript FAQ - http://jibbering.com/faq

Jul 23 '05 #3

"VK" <sc**********@yahoo.com> wrote in message
news:41*********************@news.freenet.de...
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[i].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
Jul 23 '05 #4
> "VK" <sc**********@yahoo.com> wrote in message
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[i].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
Jul 23 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: red floyd | last post by:
Is there any way to retrieve the filename given to a std::ofstream (passed in constructor or in ofstream::open())? Or, should I derive from ofstream (should probably be a template to handle...
1
by: Ravi | last post by:
My XML looks like: <role type="Joker"> <Profile id="13">ABC_Organization</Profile> </role> My XSL looks like: <xsl:variable name="prefix">profile_joker_</xsl:variable> <xsl:variable...
0
by: AG_ | last post by:
I have a .asp file looking like this: PAGE01.ASP <%@ Language=VBScript %> <% dim xml, xsl set xml = Server.CreateObject("MSXML2.DOMDocument.4.0") set xsl =...
7
by: Donna Hawkins | last post by:
I want to use javascript to redirect to a URL which has been passed as a variable (in php). I have searched but cannot find any solution. I think this code is a basic redirect: <script...
10
by: sam | last post by:
Hi, Can anyone tell me how to print a file name from ifstream? the following cout code does not print the filename I created with ifstream preivous: ifstream is; is.open ("text.txt");
24
by: ALI-R | last post by:
Hi All, First of all I think this is gonna be one of those threads :-) since I have bunch of questions which make this very controversial:-0) Ok,Let's see: I was reading an article that When...
6
by: tommaso.gastaldi | last post by:
Hi I am creating a pdf by just printing on Acrobat Distiller. This is fine. I need to create a pdf which has a given prespecified name and I do not wish that Distiller prompts me for a name....
4
by: huguogang | last post by:
Just curious, any one know what the 3 part parameter "class CString filename" would mean. The code: int TestFunc(class CString filename) { fopen(filename, "w"); } Compile using Visaul C++,...
2
by: vbaDev | last post by:
Hi. I am using Access 2000 and in my code I'm exporting a table into an Excel file (creating it), then the code needs to export another query into the same file (a new worksheet). So I needed both a...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.