Advertisement
Guest User

bee-msg

a guest
Jun 18th, 2018
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // 1. Get values from query params in URL
  2. let url = new URL(document.location.href);
  3. // this is to enable the webpage to run on its html
  4. let params = new URLSearchParams(url.search);
  5. let img_url = params.get('img-url');
  6. // this is to enable computer to track the value after the wor "img-url"
  7. let abc = params.get('msg');
  8. // name the msg in index.js as abc. then use abc as name in future command
  9.  
  10.  
  11. // console.log(url);
  12.  
  13.  
  14. // imgTag = document.querySelector('img');
  15. // imgTag.src = img_url;
  16.  
  17.  
  18. // console.log(image_url)
  19.  
  20. // 2. Get the <img> and <p> element
  21.  
  22. imgTag=document.querySelector('img');
  23. imgTag.src=img_url
  24. console.log(imgTag)
  25.  
  26. // 3. Change the innerHTML of the <p> element
  27.  
  28. hTag=document.querySelector('#message');
  29. hTag.innerHTML=abc
  30.  
  31. // }
  32. // console.log(pTag)
  33.  
  34. // // 4. Change the src attribute of <img> element
  35. window.setTimeout("closemsg()",3000);
  36.  
  37. function closemsg (){
  38.     document.getElementById("message").style.display="none";
  39. }
  40.  
  41. window.setTimeout("closeimg()",3000);
  42.  
  43. function closeimg(){
  44.     document.querySelector("img").style.visibility="hidden";
  45. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement