简体   繁体   中英

Changing external html links using javascript

Process Explaination An external application (A) would send me some html files and my application (B) is responsible to change each links inside this html page and save it in another location.

Steps of requirement

  1. An html file is placed in a folder.
  2. HTML file may contain links anywhere in it (inside a table, in the footer, inside each column ). The idea here is that place of link inside the html is not fixed and decided by application A.
  3. My application (B) should read all the available links (all the links usually are different) and change each and every link with another link (for Security purpose. These links are received from API call of another application).
  4. Save the HTML with new links.

Could someone guide me if there is any way forward to develop these using java or javascript?

If you have access to the DOM then document.queryselector will enable you to select all the relevant nodes.

I'll see if I can come up with something more fully fledged when I'm at a computer, unless someone beats me to it. :-)

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