简体   繁体   中英

How do I get the corresponding elements for a set of co-ordinates from an HTML file?

I have a csv file containing co-ordinates. I want to know all the elements which were there at that co-ordinate. I know about the function :

 document.elementFromPoint(co-ordX,co-ordY)

which returns the element at the postion. One possible solution I know about is manually coping this into the HTML source. Is there a way to automate this (copying the script into the HTML source and then opening the HTML file in the browser) since I have a number of HTML files and this needs to be done for all of them?

This question seems to be how do I add the same JS to a bunch of html files.

The simple solution is to put your code in a file called track.js and the use a decent code editor to do multi-file search and replace. I would suggest using sublime text 2 for this. Open the folder with you files and then replace

</head>

With

<script src="track.js"></script></head>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM