How to replace href using javascript regex in Firefox?
- by Andrei
I try to change some links on a webpage using the following code for jQuery on Rails
$(function () {
$('#lesson a').live('click', function () {
$.getScript(this.href.replace(/^(http...[^\/]+)?\/+(.*)$/,'/ajax/\\$2'));
return false;
});
})
This trick works for Chrome and Safari, but fails (nothing happens on click) for Firefox and Opera. What can be wrong with the code?
EDIT1:
The webpage contains:
<div id="lesson">
<a href="/subj1">Subject 1</a>
...
</div>
On click, a browser (i.e. Firefox and Opera) should make an ajax-request of /ajax/subj1.