Toggle divs without using Javascript

后端 未结 11 2035
日久生厌
日久生厌 2020-12-06 10:19

I\'d like to toggle a

, but my requirement is that it must work with javascript turned off. I would like to select a hyperlink that sta
11条回答
  •  天命终不由人
    2020-12-06 10:54

    You can't do it without using either Javascript or sending another request.

    If you can live with the extra request (that is, an added page load is OK), then the most straightforward solution is to point the link to the current URL, but add a query string parameter, e.g. http://example.com/current-page?showsearch=1. Then, on the server, check if the showsearch parameter is set, and if so, initialize the search div to be visible.

    Of course you will have to take care that the rest of your page state survives the request; you may have to use a form to be able to carry over any data the user may have entered, and this most likely means your link can't be a link, but has to be a button (because links cannot trigger form submits without Javascript).

提交回复
热议问题