banner.js 830 B

12345678910111213141516171819202122232425262728293031323334353637
  1. doBanner();
  2. function doBanner () {
  3. if (window.sessionStorage) {
  4. var s = window.sessionStorage;
  5. if (s.getItem("banner-cleared") != "true") {
  6. installBanner();
  7. }
  8. } else {
  9. installBanner();
  10. }
  11. }
  12. function installBanner () {
  13. var banner = document.createElement("div");
  14. banner.setAttribute("id", "banner");
  15. banner.setAttribute("style", "background-color: yellow; font-weight: bold; color: black; width: 100%; height: 30px; text-align: center");
  16. banner.textContent = "Stay tuned for updates..."
  17. document.body.insertBefore(banner, document.body.firstChild);
  18. banner.addEventListener("click", function () {
  19. document.body.removeChild(banner);
  20. banner = null;
  21. if (window.sessionStorage) {
  22. var s = window.sessionStorage;
  23. s.setItem("banner-cleared", "true");
  24. }
  25. });
  26. }