Reputation: 369
jQuery code is
$(document).ready(function() {
if (navigator.appVersion.indexOf("Win") != -1) {
// Computers runs windows
$("a[href$='.pdf']").each(function() {
this.href = this.href.replace("Volumes", "KP01DS0194TG");
});
}
if (navigator.appVersion.indexOf("Mac") != -1) {
// computer is a Mac
$("a[href$='.pdf']").each(function() {
this.href = this.href.replace("KP01DS0194TG", "Volumes");
});
}
});
I need it to remove a slash on the windows side , how can I go about it?
My Link is as follows href="file:///KP01DS0194TG/Quotes/Scanning/brother/Jobsheets/job no 12538.pdf">12538</a>
thats fine for mac's with volumes , however i Need it as 'file://KP01DS0194TG' for pc's , how can I remove that slash?
Upvotes: 2
Views: 1486
Reputation: 1127
If you have a link such as:
<a href="file:///[somelink]">Click Here</a>
and you want to remove one slash, use:
$('a').each(function() {
var theLink = $(this).attr('href');// get href
theLink = theLink.replace(/\/\/\//g,'//');// replace 3 slashes with 2
$(this).attr('href', theLink);
});
Upvotes: 3