doutouhe5343 2013-09-03 09:47
浏览 28
已采纳

Html额外属性作为请求调用

My Html links has extra attributes, like:

<a cat-data="175" rt-data="154" href="index.php?view=item"></a>
<a cat-data="775" rt-data="134" href="index.php?view=item"></a>
<a cat-data="575" rt-data="174" href="index.php?view=item"></a>

In this code is to see: cat-data="" and rt-data=""

If i click on this link and go to next page, can i request this data? cat-data="" and rt-data=""

  • 写回答

2条回答 默认 最新

  • duanshangying5102 2013-09-03 09:50
    关注

    Adding arbitrary attributes to an <a> element will not transfer them as part of the URL. So no, at least not as it stands.

    You can encode them in the URL in the first place:

    href="index.php?view=item&amp;rt=174&amp;cat=575"
    

    and they will be accessible through $_GET.

    You could also use JavaScript to modify the href attribute based on the other attributes, but that is needlessly complicated and dependant on JavaScript, so it is not recommended.


    Note that adding arbitrary attributes to an element will make your HTML invalid and is not recommended. HTML 5 allows custom attributes if the name starts with data-, which might be what you are trying to use here, but you are using data as a suffix when it must be a prefix.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 winform的chart曲线生成时有凸起
  • ¥15 msix packaging tool打包问题
  • ¥15 finalshell节点的搭建代码和那个端口代码教程
  • ¥15 用hfss做微带贴片阵列天线的时候分析设置有问题
  • ¥15 Centos / PETSc / PETGEM
  • ¥15 centos7.9 IPv6端口telnet和端口监控问题
  • ¥120 计算机网络的新校区组网设计
  • ¥20 完全没有学习过GAN,看了CSDN的一篇文章,里面有代码但是完全不知道如何操作
  • ¥15 使用ue5插件narrative时如何切换关卡也保存叙事任务记录
  • ¥20 海浪数据 南海地区海况数据,波浪数据