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