The parsed anchor elements can be saved in localstorage by two steps.
step1
To open https://www.yahoo.com/
in chrome
step2
To run the code in inspect--console
.
var as=document.getElementsByTagName('a');
var result='';
for(var i=0;i<as.length;i++){
result +=as[i]+" ";
}
localStorage.setItem("parse_anchor", result);
To open localstorage, key is parse_anchor
and value is result
(a long string) can be seen.
Now to write the following code and save it as parse_anchor.html
.
<html>
<script type="text/javascript">
window.location.href="https://www.yahoo.com/";
var as=document.getElementsByTagName('a');
var result='';
for(var i=0;i<as.length;i++){
result +=as[i]+" ";
}
localStorage.setItem("parse_anchor", result);
</script>
</html>
No key-value pair can be seen in chrome's localstorage when to open the file parse_anchor.html
with chrome.