douliexing2195 2014-02-12 23:43
浏览 23
已采纳

搜索机器人在查找/索引来自onclick事件的PHP代码中的此链接时会遇到问题吗?

I wanted to make my site use more PHP in order to save space on HTML code and I wanted to try using this code to make a menu that would launch different divs containing different pages or information per se, I was wondering if search bots would have difficulty navigating such a maze because of php or Javascript or both?

Here's the code,

<?php
 if($_GET['button1']){fun1();}
 if($_GET['button2']){fun2();}

 function fun1()
 {
   //creates a div with a link to google
    echo'<a href = "http://www.google.com"><div style = "height:100px; width:20px; top:100px; left:100px; background-color: black;"></div></a>';   
 }
 function fun2()
 {
 //creates a div with a link to yahoo
   echo'<a href = "http://www.yahoo.com"><div style = "height:200px; width:40px; top:200px; left:200px; background-color: red;"></div></a>';
 }
?>

<!DOCTYPE html>
<html lang="en">
  <head>
    <title></title>
  </head>
  <body>
    <button id="btnfun1" name="btnfun1" onClick='location.href="?button1=1"'>Update to 1</button>
    <button id="btnfun2" name="btnfun2" onClick='location.href="?button2=1"'>Update to 2</button>
  </body>
</html>
  • 写回答

1条回答 默认 最新

  • dongxingdu9594 2014-02-12 23:48
    关注
    1. Generally bots don't render JavaScript, so avoid that if you want those links indexed properly. Why are you even using onClick there?
    2. PHP is not delivered to the client/bot, only its output which is generally HTML. So long as your output is valid the bots should crawl it just fine.
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 stata安慰剂检验作图但是真实值不出现在图上
  • ¥15 c程序不知道为什么得不到结果
  • ¥40 复杂的限制性的商函数处理
  • ¥15 程序不包含适用于入口点的静态Main方法
  • ¥15 素材场景中光线烘焙后灯光失效
  • ¥15 请教一下各位,为什么我这个没有实现模拟点击
  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题