: A list of each of the entries are part of the contents of the article, like this:
1
2,
3,
4,
5
6
7
Of 8
9
10,
Of 11
12
|
<div Class="list">
<div Class ="item">
The first article </ div>
<div Class ="item">
The second article </ div>
.....
</ div> |
Each entry in the upper right corner of the div has a "comments" link, click to start would be for all the comments and the comments box to show that this link in the form are as follows:
1
| <a class="comment-mod" href="#"> comments </ a> |
If the user directly to see a list of articles, reviews, as well as all the comments are not shown in the box, but if other users of personal home pages such as dynamic positioning directly to this log, then they should comment on all the shows. The list of entries in a single page and view the page the same page, which you asked me to judge whether the user locate the article in the log and, if so, through JS to trigger A click on the tag events.
I try to start a number of ways to take it for granted that the A button and the label is the same as onclick () events and found no later found a number of online information, the successful resolution of this issue _ ^ ^. Solution is for IE and FF to prepare a different logic, some of the code is as follows:
1
2,
3,
4,
5
6
7
Of 8
9
10,
Of 11
12
1.3
| document. getElementsByTagName ( 'a' ) [ 0 ] ; var comment = document. getElementsByTagName ( 'a') [0];
document. all ) { if (document. all) (
/ / For IE
; Comment. Click ();
( document. createEvent ) { ) Else if (document. createEvent) (
/ / FOR DOM2
document. createEvent ( 'HTMLEvents' ) ; var ev = document. createEvent ( 'HTMLEvents');
'click' , false , true ) ; ev. initEvent ( 'click', false, true);
ev ) ; comment. dispatchEvent (ev);
) |
The above code in IE6, IE7 and FireFox 3 under through the test.
That learning experience, the record here.
Reference: http://ued.koubei.com/?p=400
Collection-sharing