Could someone help me with this short piece of code?
Right now when I click thumbnail image on my site it creates url in the address bar. But url has .jpg at the end.
How should I modify the code so that it won’t show .jpg at the end of the url?
This piece of code also opens Colorbox image automatically if user enters site with url like http://www.domain.com/#image.jpg so naturally the change to the code should affect also to that.
Thanks!
jQuery(function() {
var id, group;
group = jQuery("a[rel='lightbox[63]']").colorbox({
onComplete: function() {
window.location.hash = (this.pathname.match(/\/([^\/?#]+)$/i) || [,''])[1];
},
onClosed: function() {
location.hash = '';
}
});
id = location.hash.replace(/^\#/, '');
group.filter('[href$="'+id+'"]').eq(0).click();
});
Replace this:
With this:
Explanation
my_str.lastIndexOf(".")returns the position of the last.character in the stringmy_strmy_str.substring(n, m), wherenandmare numbers returns the characters in amy_strbeginning atnthroughmcharacters – https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/String/substrExample
http://jsbin.com/uqufev/1/edit