I am trying to create a small module. I have uploaded .html file and read that file via textContent. Now I have written a small function for all links. Function name is linkGenerate(). But that function can't read the uploaded text. Function works fine if i use innerHTML. But I don't want to use it. I want to see the uploaded file as a text format so that I can save it back. can anyone tell me how can i read uploaded file and select all links from the that file.
Here is the snippet
function linkGenerate() {
let links = result.getElementsByTagName('a').textContent;
// let links = result.getElementsByTagName('a');
// let links = result.querySelectorAll("[href]");
for(let link of links)
{
let curhref = link.href;
if(curhref.indexOf('http') > -1)
{
link.href = curhref.replace(/(\?|&)elqTrackId=[a-z0-9]+(&elqTrack=true)?/, '');
if(link.href.indexOf('ea=') > -1)
{
link.href += '&utm_source=iconnect&utm_medium=email&utm_campaign={{Approved_Document_vod__c.Vault_Document_ID_vod__c}}&emailId={{Approved_Document_vod__c.Vault_Document_ID_vod__c}}&codsId={{Account.CODS_External_Id__c}}&utm_term=';
}
else
{
link.href += '?utm_source=iconnect&utm_medium=email&utm_campaign={{Approved_Document_vod__c.Vault_Document_ID_vod__c}}&emailId={{Approved_Document_vod__c.Vault_Document_ID_vod__c}}&codsId={{Account.CODS_External_Id__c}}&utm_term=';
}
}
}
}
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Zip</title>
<!-- Bootstrap CSS
==================== -->
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">
<!-- Custom Stylesheet
===================== -->
</head>
<body>
<nav class="navbar navbar-expand-lg navbar-light bg-light">
<a class="navbar-brand" href="#">test</a>
</nav>
<div class="container-fluid">
<div class="row mt-5">
<div class="col">
<div class="input-group mb-3">
<div class="input-group-prepend">
</div>
<div class="custom-file">
<input type="file" class="custom-file-input" id="file" onchange="return fileValidation()">
<label class="custom-file-label" for="inputGroupFile01">Choose file</label>
</div>
</div>
<!-- Output Div -->
<div id="result" contenteditable="true"></div>
</div>
</div>
</div>
<!-- Custom Script
================ -->
<script src="assets/js/script.js"></script>
</body>
</html>
But I don't want to use it. I want to see the uploaded file as a text format so that I can save it backWhat do you need to modify before saving that you cannot do by treating the file as HTML?result?resultis the div where I have shown the uploaded file @trincotresultvariable and that illustrates the problem?