JavaScript: Know which article? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

JavaScript: Know which article?

Hey there! I am building a website with articles where users can write comments to each article (comments stored on firebase). In order to add/retrieve the comments to/from the related node (there's a node for each article containing its appertaining comments), the script needs to know on which page/which article it is. How would that work? Thanks, Ltzu

12th Jul 2017, 10:29 AM
Ltzu
Ltzu - avatar
2 Answers
+ 1
Perhaps you could use window.location to get the pathname of the article's HTML file and store it with the comments.
16th Jul 2017, 12:03 AM
James
James - avatar
+ 1
@James Seems to be a god solution, thanks a lot! :)
16th Jul 2017, 8:01 AM
Ltzu
Ltzu - avatar