如何设置 cookie 来记住打开的选项卡?选项卡是使用 Coldfusion & 创建的。 JavaScript
这可能比我做的更简单,但我就是不知道该怎么做。我得到的是在 Coldfusion 中创建的选项卡式部分。输出是所选部分的类名包含字符串“tab_selected(+在coldfusion中创建的UUID)”,而未选择的选项卡部分的类名包含字符串“tab_unselected(+在coldfusion中创建的UUID)”。当您单击未选择的选项卡时,类将更改为“tab_selected(+ UUID)”,并且所有其他选项卡都会进行相应设置。
我试图做的是,使用 javascript,当您退出页面时,它会搜索具有包含字符串“tab_selected”的类的元素,然后使用该元素的 id 设置 cookie...
这就是全部我现在(在 JQuery 中)...而且它可能是非常错误的。请帮忙。
$(window).unload( function () {
$("selector[name*='tab_selected_text']").cookie("TABS_REMEMBER", 1, { expires: null });
});
This is probably more simple than I'm making it but I just can't figure out how to do it. What I've got are tabbed sections created in Coldfusion. The output is that the selected section has a class name that contains the string "tab_selected (+ the UUID created in coldfusion)" versus the unselected tab sections whose class names contain the string "tab_unselected (+ the UUID created in coldfusion)". When you click on the unselected tabs the class is changed to "tab_selected (+ the UUID)" and all the other tabs are set accordingly.
What I'm attempting to do is, using javascript, when you exit the page it searches for the element that has the class that contains the string "tab_selected" and then sets the cookie with the id of that element...
This is all I have at this point (in JQuery)...And it could be terribly wrong. Please help.
$(window).unload( function () {
$("selector[name*='tab_selected_text']").cookie("TABS_REMEMBER", 1, { expires: null });
});
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
由于您使用的是 jquery 及其 cookie 插件,因此它非常简单且自动。
当您声明选项卡时,请使用此:
它将导致选项卡组件记住上次使用的选项卡。
Since you're using jquery and its cookie plugin, it's very easy and automatic.
When you declare your tabs use this:
It will cause to tabs component memorize the last used tab.