Passing on variables to functions
|
|
Hey there, I have the following problem:
Now I get the error message "links[i] has no properties".
Any ideas?
|
|
|
onload: rs(i)
});
}
}
function rs(i) {
return function(e) {
var title = e.responseText.split("<title>")[1].split("</title>")[0];
links[i].setAttribute("title", title);
};
}
|
|
|
Thanks a lot, works like a charm. |
|
|
BTW, why would you need "g" flag in the regexp? I'd rewrite it that way:
var links = document.links, urls = new Array(), re = /imdb\.com\/title\//i;
for (var i=0; i < links.length; i++) {
if (re.test(links[i].href)) {
|
|
|
The 'g' flag shouldn't make much of a difference, as the regex should only appear once in the string. If it does appear twice for some reason, then it would replace it in both places and Mikado is right. In general, though, it's unlikely that it will matter. -Joel |
