Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums JavaScript how to set jquery to remain on same page even after refreshing

  • This topic is empty.
Viewing 12 posts - 1 through 12 (of 12 total)
  • Author
    Posts
  • #204872
    harry
    Participant

    hi everyone i have multiple tabs on same page .while refreshing the page it goes to default tab by itself and i want to remain on same tab whatever we are visiting even after refreshing the page .

    here is the link https://jsfiddle.net/zy9bcjmt/

    Thanks in Advance Guys…….

    #204879
    Shikkediel
    Participant

    Only seems possible with a cookie or something…
    A plain refresh won’t be able to ‘remember’ any data.

    #204881
    harry
    Participant

    can you suggest how to do it by local storage i tried but its not working

    #204882
    Shikkediel
    Participant

    That would probably be the most appropriate solution. Maybe you can post the code you’ve used? Could be a lot of things causing it to not work (yet).

    #204883
    harry
    Participant

    here is the codepen link http://codepen.io/anon/pen/MwGOMO please check it

    #204885
    Shikkediel
    Participant

    Only semi tested but I think it would have to look something like this :

    https://jsfiddle.net/re234qt0/

    #204887
    harry
    Participant

    thanks a lot it working thank you friend……….

    #204890
    Shikkediel
    Participant

    You’re welcome, I see I snuck in a $(window) but if it works I guess you don’t need to use the extended jQuery(). If it suddenly stops working on a site that has the $ character reserved then changing that to jQuery(window) should fix it.

    Edit – updated the fiddle.

    #204892
    Shikkediel
    Participant

    Thanks in return by the way, I never realised this was such an easy cookie alternative (for trivial data anyway).

    :-)

    #204893
    harry
    Participant

    thanks for your suggestion friend and i need another help friend is there any way to clear a form value by using jquery or javascript . i tried but there is some error and i cant find it can you please

    http://jsfiddle.net/3waddu91/

    #204894
    Shikkediel
    Participant

    I’ll have a look at that. In the meantime, although I don’t think this particular example could lead to a security issue (anyone could change the local storage, really) a minor check would be better anyway. Just to see if the value matches with anything it’s supposed to be. Extend the var cases with new ids when there are more tabs involved…

    https://jsfiddle.net/f7h9ursn/

    #204897
    Shikkediel
    Participant

    I think I’ll refer to this topic on the other question…

    Clear form fields with jQuery

Viewing 12 posts - 1 through 12 (of 12 total)
  • The forum ‘JavaScript’ is closed to new topics and replies.