Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // 1. Get values from query params in URL
- let url = new URL(document.location.href);
- // this is to enable the webpage to run on its html
- let params = new URLSearchParams(url.search);
- let img_url = params.get('img-url');
- // this is to enable computer to track the value after the wor "img-url"
- let abc = params.get('msg');
- // name the msg in index.js as abc. then use abc as name in future command
- // console.log(url);
- // imgTag = document.querySelector('img');
- // imgTag.src = img_url;
- // console.log(image_url)
- // 2. Get the <img> and <p> element
- imgTag=document.querySelector('img');
- imgTag.src=img_url
- console.log(imgTag)
- // 3. Change the innerHTML of the <p> element
- hTag=document.querySelector('#message');
- hTag.innerHTML=abc
- // }
- // console.log(pTag)
- // // 4. Change the src attribute of <img> element
- window.setTimeout("closemsg()",3000);
- function closemsg (){
- document.getElementById("message").style.display="none";
- }
- window.setTimeout("closeimg()",3000);
- function closeimg(){
- document.querySelector("img").style.visibility="hidden";
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement