1.html

  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="UTF-8">
  5. <title>Title</title>
  6. </head>
  7. <body>
  8. <div id="div" style="height: 200px;width: 200px" >
  9. <button id="button">点击</button>
  10. <button id="button2">点击</button>
  11. </div>
  12. <script>
  13. var div= document.getElementById("div");
  14. var button= document.getElementById("button");
  15. var button2= document.getElementById("button2");
  16. var bgcolor = window.localStorage.getItem('bgcolor');
  17. console.log(bgcolor)
  18. button.onclick=function () {
  19. bgcolor =prompt("请输入颜色");
  20. window.localStorage.setItem('bgcolor',bgcolor);
  21. div.style.background = bgcolor;
  22. }
  23. button2.onclick=function () {
  24. parent.location="2.html"
  25. }
  26. </script>
  27. </body>
  28. </html>

2.html

  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="UTF-8">
  5. <title>2</title>
  6. </head>
  7. <body id="body">
  8. <script>
  9. onload=function () {
  10. bgcolor = window.localStorage.getItem('bgcolor');
  11. document.getElementById("body").style.background=bgcolor;
  12. }
  13. </script>
  14. </body>
  15. </html>

更多相关文章

  1. 带有二级分类的导航
  2. Element Plus组件-按钮、图标、ColorPicker 颜色选择器、日历、R
  3. phpstorm 配置环境本地服务器教程
  4. html5实现点击弹出图片功能
  5. Vue一个通用的组件传递点击事件的两种种简单方法
  6. 三分钟!意派Epub360制作高端H5邀请函
  7. 字体图标引用、无序列表颜色设置、盒模型
  8. Visual Studio Code如何切换为简体中文
  9. php之session实战

随机推荐

  1. 查询从每个组中查找第二大值
  2. 2018年5月05日 Python3-Mysql连接
  3. 数据库Mysql的学习(一)
  4. 解决Myeclipse下Debug出现Source not fou
  5. ORACLE 两表关联更新
  6. MySQL乐观锁在分布式场景下的实践
  7. 求sql存储过程!--创建存储过程统计各仓库
  8. SQL语句的优化
  9. Asp.net中Web.config连接字符串及配置数
  10. yahoo mysql性能监控工具使用