javascript - 即使您移动到另一个页面并将弹出数据带到另一个页面,如何使弹出窗口弹出?

标签 javascript jquery html css popup

我在弹出窗口中有一个提交表单,我的要求是弹出窗口及其数据保持不变,即使我移动到另一个页面,直到我提交表单数据弹出窗口应该显示在所有包含内容的页面上。

为了在我移动到另一个页面时保持弹出窗口弹出,我正在使用 localstorage 但我无法获取弹出数据

$("#call_log").click(function(e) {
  //localStorage.timerpopup="active";
  document.getElementById("test").style.display = "block";
});
$("img.close").click(function(e) {
  $("#test").fadeOut();
});
#test {
  background: lightgrey;
  padding: 10px;
  position: relative;
  padding-top: 20px;
  top: 100px;
  width: 450px;
  border: 5px solid #ddd;
}

img.close {
  position: absolute;
  right: 0px;
  top: 0px;
  height: 30px;
  width: 30px;
  cursor: pointer;
}
<script src="https://code.jquery.com/jquery-1.12.4.js"></script>
<script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script>
<input type="button" value="Call log" id="call_log">
<div id="test" style="display: none;">
  Submit form
  <form action="save_popup_data.php" method="post">
    <input type="text" name="currenturl" id="currenturl" value="12345">
    <input type="text" name="starttime" id="starttime" value="3.00">
    <input type="text" name="endtime" id="endtime" value="4.00">
    <input type="text" name="duration_hours" id="duration_hours" value="1">
    <input type="text" name="duration_minutes" id="duration_minutes" value="30">
    <input type="submit" name="save" id="save" value="Save" style=" padding: 5px 15px;">
  </form>
  <img class="close" src="https://cdn3.iconfinder.com/data/icons/status/100/close_4-512.png" alt="">
</div>

最佳答案

$("#call_log").click(function(e) {
  //localStorage.timerpopup="active";
  document.getElementById("test").style.display = "block";
});
$("img.close").click(function(e) {
  $("#test").fadeOut();
});
#test {
  background: lightgrey;
  padding: 10px;
  position: relative;
  padding-top: 20px;
  top: 100px;
  width: 450px;
  border: 5px solid #ddd;
}

img.close {
  position: absolute;
  right: 0px;
  top: 0px;
  height: 30px;
  width: 30px;
  cursor: pointer;
}
<script src="https://code.jquery.com/jquery-1.12.4.js"></script>
<script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script>
<input type="button" value="Call log" id="call_log">
<div id="test" style="display: none;">
  Submit form
  <form action="save_popup_data.php" method="post">
    <input type="text" name="currenturl" id="currenturl" value="12345">
    <input type="text" name="starttime" id="starttime" value="3.00">
    <input type="text" name="endtime" id="endtime" value="4.00">
    <input type="text" name="duration_hours" id="duration_hours" value="1">
    <input type="text" name="duration_minutes" id="duration_minutes" value="30">
    <input type="submit" name="save" id="save" value="Save" style=" padding: 5px 15px;">
  </form>
  <img class="close" src="https://cdn3.iconfinder.com/data/icons/status/100/close_4-512.png" alt="">
</div>

关于javascript - 即使您移动到另一个页面并将弹出数据带到另一个页面,如何使弹出窗口弹出?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42928153/

相关文章:

javascript - 将 HTML 数据属性设置为整数数组

javascript - Promises 相对于 CPS 和 Continuation Functor/Monad 有哪些优势?

javascript - 使用 jQuery 使多个物体在同一轨道上旋转但位置不同

javascript - 从外部 API 为 React 组件绑定(bind)数据

html - 美化本地链接不正确

Javascript 多子数组

javascript - 从nodejs服务器登录到另一个站点

javascript - 如何在父子层次结构中显示表格?

html - 如何在 flexbox 布局中将 div 包装在父 div 中?

html - 宽度过渡 - div 重叠