How to store a value of variable in javascript for new tab opened in browser

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP



How to store a value of variable in javascript for new tab opened in browser



This function works fine as well as I'm getting currentUrl here:


currentUrl


var currentUrl;

function onFileSelected(event)
var selectedFile = event.target.files[0];
var reader = new FileReader();

var result = document.getElementById("result");

reader.onload = function(event)
currentUrl = event.target.result;
result.innerHTML = event.target.result;
;

reader.readAsText(selectedFile);
return currentUrl;



The problem is that this is launching a new Chrome window and the value of my currentUrl variable is lost:


currentUrl


function launchChromeAndRunLighthouse(currentUrl, opts, config = null)
const cmd = `lighthouse $currentUrl --chrome-flags="--headless"`;

exec(cmd, (error, stdout, stderr) =>
if (error !== null)
console.log(`exec error: $error`, stderr);

);



I have an HTML file which takes a text file as input and the text file contains multiple URLs. I want to read the text file and grab that URL in my currentUrl variable. Currently I'm able to read the text file and also able to grab the current URL in the currentURL variable but when I run the launchLighthouse function it's launching a new Chrome window and thus my variable is lost and it shows me undefined variable.


currentUrl


currentURL


launchLighthouse









By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Popular posts from this blog

Firebase Auth - with Email and Password - Check user already registered

Dynamically update html content plain JS

How to determine optimal route across keyboard