Dr John Stockton said the following on 9/4/2005 8:48 AM:
JRS: In article <
[email protected]>, dated Fri, 2 Sep
2005 17:14:40, seen in Randy Webb
References to hand indicate that document.write (which I did not use)
can take multiple comma-separated parameters. Your method has
unnecessary string manipulation, but you have clarified the quote-marks.
If I were writing that for myself, it would look something like this:
var myVar = '';
for (j=0 ; j<10 ; j++){
myVar += '<img src="graphics\\fig-'+j+'.gif" onmouseover="alert('+j+');">';
}
document.write(myVar);
Where the myVar line is, obviously, on one line.
But you are correct, the original did double string manipulation.
But, to add dynamic event handles to every link on a page, I would do as
I said to begin with. Loop through the page and dynamically add them,
not dynamically create the links.
Dynamically added event handlers enhance the page for JS users.
Dynamically created links makes the page totally unusable by non-JS users.
The above way only works if it is a continuous list of links. Not many
sites fall into that category.
Mine is as I tested it, and works; so, in fact, does yours.
That goes without saying.
Your original response to the OP wasn't helpful, either.
Yes it was, you just didn't realize it.