I am working on parsing a specific URL contents and display request parameters in alert box.
What should I do to display request parameters in an alert box ?
Below is the code I am working
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<<script type="text/javascript">
let url = "https://example.com/path/to/page?name=ferret&color=purple";
let params = (new URL(url)).searchParams;
params.get('name') # => "n1"
params.getAll('name') # => ["n1", "n2"]
</script>
</body>
</html>
add alert('contents of alert go here'); // this line
alert(myVar); // or this line
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<script type="text/javascript">
let url = "https://example.com/path/to/page?name=ferret&color=purple";
let params = (new URL(url)).searchParams;
params.get('name') # => "n1"
params.getAll('name') # => ["n1", "n2"]
myVar = 'some content';
alert('contents of alert go here'); // this line
alert(myVar); // or this line
</script>
</body>
</html>