如何记住当前点击的网址? javascript?PHP? [英] How to remember the currently clicked url? javascript?PHP?

查看:112
本文介绍了如何记住当前点击的网址? javascript?PHP?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个html选择列表菜单,当用户选择一个选项时,他/她将被重定向到所选页面. 例如,他/她将被重定向到 http://example.com/towns/Faizabad 下面是选择菜单,它用作跳转菜单.

I have a html select list menu,when user select an option he/she is redirected to the page of choice. for example he/she will be redirected to http://example.com/towns/Faizabad below is the selection menu,this acts as a jump menu.

  <select name="cities">
  <option value="towns/Antaliya" id="city1">Antaliya</option>
  <option value="towns/Faizabad" id="city2">Faizabad</option>
  </select>

当用户(登录/匿名)选择城市时,我需要...以添加选定的属性,并记住该选项几天,直到用户再次更改为另一个选项. 我对Javascript/jquery不太满意.我认为可以通过Cookie来实现. 任何帮助将不胜感激.

I need when user(logged/anonymous) selects a city... to add attributed selected, and remember the option for several days until user changes again to another option. I am not good with Javascript/jquery.. i think it can be achived with cookies. Any help will be appreciated.

推荐答案

您可以使用此插件 http://www.ashishblog.com/blog/jquery-cookie-example/,然后在选择城市后设置您的Cookie

You can use this plug-in http://www.ashishblog.com/blog/jquery-cookie-example/ then set your cookies after cities selection

$('select[name=\'cities\']').change(function(){
$.cookie('city', $(this).val());
});

这篇关于如何记住当前点击的网址? javascript?PHP?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆