Get id element of multiple html pages

No. There’s a basic misunderstanding here. You cannot look at something without looking at it. JavaScript does not make the laws of physical reality change.

If you need to get the IDs from the HTML on another HTML page, you have to literally load that page. You can do this programmatically using JavaScript (look up AJAX), but you have to load the HTML page, it doesn’t exist somewhere floating around in the ether just waiting for you to grab things from it.