Advertisement
Guest User

Untitled

a guest
Mar 20th, 2019
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.05 KB | None | 0 0
  1. <form method="GET">
  2. <input type="hidden" name="clicked" value="true" />
  3. <input type="submit" />
  4. </form>
  5.  
  6. function getParameterByName(name) {
  7. name = name.replace(/[[]/, "\[").replace(/[]]/, "\]");
  8. var regex = new RegExp("[\?&]" + name + "=([^&#]*)"),
  9. results = regex.exec(location.search);
  10. return results === null ? "" : decodeURIComponent(results[1].replace(/+/g, " "));
  11. }
  12.  
  13. var clicked = getParameterByName('clicked');
  14.  
  15. $('input[type="submit"][value="Search"]').click(function() {
  16. sessionStorage.setItem('clicked', 'true');
  17. });
  18.  
  19. var clicked = sessionStorage.getItem('clicked');
  20.  
  21. sessionStorage.removeItem('clicked');
  22.  
  23. //set
  24. localStorage.setItem('myObject', JSON.stringify(myObject));
  25.  
  26. //get
  27. var myObject = JSON.parse(localStorage.getItem('myObject'));
  28.  
  29. $('input[type="submit"][value="Search"]').click(function() {
  30. $.cookie('clicked', 'true', {expires: 1}); // expires in 1 day
  31. });
  32.  
  33. var clicked = $.cookie('clicked');
  34.  
  35. if(clicked === "true") {
  36. //doYourStuff();
  37. $.cookie('clicked', null);
  38. }
  39.  
  40. window.name = "my value"
  41.  
  42. window.name = JSON.stringify({ clicked: true });
  43.  
  44. <script src="jquery.js" type="text/javascript"></script>
  45. </head>
  46. <body>
  47. <form method="POST">
  48. <input type="text" name="name" value="" />
  49. <input type="submit" value="Search" />
  50. <input type="hidden" />
  51. <input type="hidden" />
  52. </form>
  53. <script type="text/javascript">
  54. function show() {
  55. return $("form input[type=hidden]")
  56. .replaceWith(function(i, el) {
  57. return "<input type=text>"
  58. });
  59. }
  60.  
  61. $.holdReady(true);
  62. if (history.state !== null && history.state.clicked === true) {
  63. // show hidden fields
  64. // if `history.state.clicked === true` ,
  65. // replace `input type=hidden` with `input type=text`
  66. show();
  67. console.log(history);
  68.  
  69. } else {
  70. // don't show hidden fields
  71. console.log(history);
  72. }
  73. $.holdReady(false);
  74.  
  75. $(document).ready(function() {
  76.  
  77. $("input[type=submit][value=Search]")
  78. .on("click", function(e) {
  79. e.preventDefault();
  80. if (history.state === null) {
  81. // do stuff
  82. history.pushState({"clicked":true});
  83. // replace `input type=hidden` with `input type=text`
  84. show();
  85. console.log(history);
  86. } else {
  87. // do other stuff
  88. };
  89. });
  90.  
  91. });
  92. </script>
  93. </body>
  94.  
  95. if(localeStorage.getItem("clicked") === null)
  96. localeStorage.setItem("clicked", "FALSE"); // for the first time
  97.  
  98. $(document).ready(function() {
  99.  
  100. $("input[type='submit'][value='Search']").attr("onclick", "form.act.value='detailSearch';return true;");
  101.  
  102. var clicked = localeStorage.getItem("clicked") == "FALSE" ? "TRUE" : "FALSE";
  103.  
  104. localeStorage.setItem("clicked", clicked);
  105.  
  106. if (clicked == "TRUE") {
  107. // show hidden fields
  108. } else {
  109. // don't show hidden fields
  110. }
  111.  
  112. });
  113.  
  114. $("input[type='submit'][value='Search']").click(function(){
  115. form.act.value='detailSearch';
  116. clicked = true;
  117. return true;
  118. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement