, .
source click, href - .
, .
The simplest but not supported by many browsers is to use let, which allows you to use the block area.
let source = thisLink.getAttribute('href');
jsFiddle . It worked in Firefox, but not in Chrome.
In 2038, when we are dealing with the problem of 2038 , and all browsers have implemented ES6, this will be the standard way to fix this problem.
A more complicated method to understand and implement, compatible with all browsers, is to break the closure with a pattern such as ...
thisLink.onclick = (function(src) {
return function(){
showPic(src);
return false;
}
})(source);
jsFiddle .
source
share