简体   繁体   English

使用 javascript 更改外部 html 链接

[英]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.过程说明 外部应用程序 (A) 将向我发送一些 html 文件,而我的应用程序 (B) 负责更改此 html 页面内的每个链接并将其保存在另一个位置。

Steps of requirement需求步骤

  1. An html file is placed in a folder. html 文件放置在文件夹中。
  2. HTML file may contain links anywhere in it (inside a table, in the footer, inside each column ). HTML 文件可能包含其中任何位置的链接(在表格内、在页脚内、在每列内)。 The idea here is that place of link inside the html is not fixed and decided by application A.这里的想法是 html 内的链接位置不是固定的,由应用程序 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).我的应用程序 (B) 应该读取所有可用的链接(所有链接通常都是不同的)并将每个链接更改为另一个链接(出于安全目的。这些链接是从另一个应用程序的 API 调用接收的)。
  4. Save the HTML with new links.使用新链接保存 HTML。

Could someone guide me if there is any way forward to develop these using java or javascript?如果有任何方法可以使用 java 或 javascript 开发这些,有人可以指导我吗?

If you have access to the DOM then document.queryselector will enable you to select all the relevant nodes.如果您有权访问 DOM,则 document.queryselector 将使您能够访问 select 所有相关节点。

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.当我在电脑前时,我会看看我是否能想出更成熟的东西,除非有人打败了我。 :-) :-)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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