Daniish
asked on
How is this Javascript extended to replace the domain name etc?
Hello,
I'm using the Javascript thumbnail viewer called Highslide (http://highslide.com/). One of the commands that are available allow an image filename to be added as a image caption.
For example:
hs.captionEval = 'this.content.src.replace( \'.jpg\', \'\')';
...will remove the '.jpg' from the filename.
Please can some tell me how i can extend this so that the current caption can be changed from:
http://www.globexposure.net/includes/travel_pics/163/Toby Texas%20Chainsaw%20Massacr e.jpg
to
Toby Texas Chainsaw Massacre
Please note, however, that the '163' element of the current name is an id variable, and will therefore change between images.
Many thanks for your help
I'm using the Javascript thumbnail viewer called Highslide (http://highslide.com/). One of the commands that are available allow an image filename to be added as a image caption.
For example:
hs.captionEval = 'this.content.src.replace(
...will remove the '.jpg' from the filename.
Please can some tell me how i can extend this so that the current caption can be changed from:
http://www.globexposure.net/includes/travel_pics/163/Toby Texas%20Chainsaw%20Massacr
to
Toby Texas Chainsaw Massacre
Please note, however, that the '163' element of the current name is an id variable, and will therefore change between images.
Many thanks for your help
try:
var str="http://www.globexposure.net/includes/travel_pics/163/Toby Texas%20Chainsaw%20Massacre.jpg";
var result = str.replace( /.*\/([^\/]+)\.jpg$/i,"$1")
alert( result );
ASKER
Blu - your code makes the whole caption area under the images, disappear!
Hielo - sorry perhaps i wasn't clear, each image on my site (there will be hundreds) needs to have its filename set to be the caption. Therefore, it is not possible to hardcode the var 'str'.
Is there a way var str could be set dynamically?
Hielo - sorry perhaps i wasn't clear, each image on my site (there will be hundreds) needs to have its filename set to be the caption. Therefore, it is not possible to hardcode the var 'str'.
Is there a way var str could be set dynamically?
the hard-coded value was just an example. What you really need is:
hs.captionEval = 'this.content.src.replace( /.*\/([^\/]+)\.jpg$/i,"$1")';
ASKER
Hi Hielo,
It looks very complex, but i'm afraid that it doesn't appear to do anything. I can't begin to understand what it does but hopefully you can see what's wrong.
Thanks again but please keep trying.
It looks very complex, but i'm afraid that it doesn't appear to do anything. I can't begin to understand what it does but hopefully you can see what's wrong.
Thanks again but please keep trying.
>>but please keep trying.
Yeah right. Not in the dark!
Yeah right. Not in the dark!
Try this:
myString = this.content.src.replace(\ '.jpg\', \'\');
//add this line after:
hs.captionEval= hs.captionEval.substr(mySt ring.lastI ndexOf('/' )+1));
myString = this.content.src.replace(\
//add this line after:
hs.captionEval= hs.captionEval.substr(mySt
ASKER
Hi Blu - your code seems to hide both the caption and controlbar
You can see the effect here www.globexposure.net/index_blu.php
as opposed to the normal look www.globexposure.net/index.php
You can see the effect here www.globexposure.net/index_blu.php
as opposed to the normal look www.globexposure.net/index.php
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
hs.captionEval = this.content.src.replace(\
//add this line after:
hs.captionEval= hs.captionEval.substr(mySt