【问题标题】:open clicked link in newpage [closed]在新页面中打开点击的链接[关闭]
【发布时间】:2012-01-25 00:57:18
【问题描述】:

我有这样的导航菜单的索引页面

man
  caps
  shirt
  jeans

woman
  caps
  shirt
  jeans

到目前为止,我做了什么,通过单击每个链接说牛仔裤来自男人,文本通过 jquery ajax 发送到服务器上的 php,它检索所有男人牛仔裤图像并将其发送回索引页面,清空主页面-内容区域并在那里显示

现在,当我重新加载页面时,所有显示主页/索引页面的页面都消失了

我看到了 cookie,但无法为链接设置它将 cookie 设置为该图像的图像。

我想到的另一件事是,当用户单击链接时,该页面会显示为 products.html此页面的主要内容充满了单击的链接图像,因此如果单击重新加载,它将保留在同一页面上以摆脱 cookie 龙,但无法为我的第二个想法编写代码

问候萨吉德

【问题讨论】:

  • 我放弃了阅读。请添加标点符号(包括大写字母、句号、逗号、撇号和分段符)。
  • 哇,这真是一句连贯的句子。请花一点时间把它分解成可读的部分。
  • 你需要用到hash url,看看这个,希望对你有帮助stackoverflow.com/questions/4113397/jquery-url-hash
  • @heera 请输入它作为答案它帮助我让我标记它然后

标签: php jquery html


【解决方案1】:
 <a href="#graphicsDesign">Graphics</a>
 if(window.location.hash === "graphicsDesign" ||
    window.location.hash === "somethingElse") {
    loadContent(window.location.hash);
 }

参考Working with single page websites and maintaining state using a URL hash and jQuery

【讨论】:

    【解决方案2】:

    当他们点击“牛仔裤”(比如说)时,您可以将页面设置为 www.mysite.com/#jeans。 刷新页面后,使用 Javascript 选择 #jeans 并加载相应的图像。

    虽然我不确定你为什么不能只使用 cookie(尽管我必须承认我的眼睛到那时已经累了)。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-07-16
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多