目前正致力于使用ajax进行某些分页的事情。 我要做的是在某些链接的末尾添加类似referal = 3的内容,然后当他们转到该链接时,我将插入一个带窗口位置的后退按钮,例如:
用户使用ajax分页,转到第3页我会添加?ref = 3到链接的末尾或者其他什么东西所以它希望这样:
http://foo.com/somepage/?ref=3
(不确定这是否是一种正确的做法)
然后用户点击该链接,我将在该页面上添加一个带有该链接的后退按钮。
因此,当他们使用生成的按钮返回主页时,window.location.href将是:
http://foo.com?ref=3
这个想法是,当他们点击后退按钮时,ajax分页将加载到第3页。
我不知道怎么解释这个,但是有谁知道我会怎样做依赖于window.location.href的条件语句?
Currently working on something which uses ajax for some pagination. What I'm looking to do is add something like referal=3 to the end of some links then when they go to that link I'll insert a back button with the window location for example:
User uses the ajax pagination, goes to page 3 I'll add ?ref=3 to the end of the link or something so it would like this this:
http://foo.com/somepage/?ref=3
(not sure if that's a corrent way of doing it)
Then the user clicks that link and I'll append a back button on that page with that link.
So when they go back to the homepage using the generated button the window.location.href will be:
http://foo.com?ref=3
The idea is that when they click that back button, the ajax pagination will load to page 3.
I'm not sure how else to explain this, but does anyone know how I would go about doing a conditional statement dependant on the window.location.href?
最满意答案
要查找url是否包含某些字符串:
if (document.location.href.search("ref=3")!=-1){ alert('got ref=3'); }To find a if the url contains some string:
if (document.location.href.search("ref=3")!=-1){ alert('got ref=3'); }更多推荐
发布评论