Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <form method="GET">
- <input type="hidden" name="clicked" value="true" />
- <input type="submit" />
- </form>
- function getParameterByName(name) {
- name = name.replace(/[[]/, "\[").replace(/[]]/, "\]");
- var regex = new RegExp("[\?&]" + name + "=([^&#]*)"),
- results = regex.exec(location.search);
- return results === null ? "" : decodeURIComponent(results[1].replace(/+/g, " "));
- }
- var clicked = getParameterByName('clicked');
- $('input[type="submit"][value="Search"]').click(function() {
- sessionStorage.setItem('clicked', 'true');
- });
- var clicked = sessionStorage.getItem('clicked');
- sessionStorage.removeItem('clicked');
- //set
- localStorage.setItem('myObject', JSON.stringify(myObject));
- //get
- var myObject = JSON.parse(localStorage.getItem('myObject'));
- $('input[type="submit"][value="Search"]').click(function() {
- $.cookie('clicked', 'true', {expires: 1}); // expires in 1 day
- });
- var clicked = $.cookie('clicked');
- if(clicked === "true") {
- //doYourStuff();
- $.cookie('clicked', null);
- }
- window.name = "my value"
- window.name = JSON.stringify({ clicked: true });
- <script src="jquery.js" type="text/javascript"></script>
- </head>
- <body>
- <form method="POST">
- <input type="text" name="name" value="" />
- <input type="submit" value="Search" />
- <input type="hidden" />
- <input type="hidden" />
- </form>
- <script type="text/javascript">
- function show() {
- return $("form input[type=hidden]")
- .replaceWith(function(i, el) {
- return "<input type=text>"
- });
- }
- $.holdReady(true);
- if (history.state !== null && history.state.clicked === true) {
- // show hidden fields
- // if `history.state.clicked === true` ,
- // replace `input type=hidden` with `input type=text`
- show();
- console.log(history);
- } else {
- // don't show hidden fields
- console.log(history);
- }
- $.holdReady(false);
- $(document).ready(function() {
- $("input[type=submit][value=Search]")
- .on("click", function(e) {
- e.preventDefault();
- if (history.state === null) {
- // do stuff
- history.pushState({"clicked":true});
- // replace `input type=hidden` with `input type=text`
- show();
- console.log(history);
- } else {
- // do other stuff
- };
- });
- });
- </script>
- </body>
- if(localeStorage.getItem("clicked") === null)
- localeStorage.setItem("clicked", "FALSE"); // for the first time
- $(document).ready(function() {
- $("input[type='submit'][value='Search']").attr("onclick", "form.act.value='detailSearch';return true;");
- var clicked = localeStorage.getItem("clicked") == "FALSE" ? "TRUE" : "FALSE";
- localeStorage.setItem("clicked", clicked);
- if (clicked == "TRUE") {
- // show hidden fields
- } else {
- // don't show hidden fields
- }
- });
- $("input[type='submit'][value='Search']").click(function(){
- form.act.value='detailSearch';
- clicked = true;
- return true;
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement