2014-02-12 51 views
0

我想使我的網站使用更多的PHP爲了節省HTML代碼的空間,我想嘗試使用此代碼來創建一個菜單,將啓動不同的div s包含不同的頁面或信息本身,我想知道如果搜索機器人由於php或Javascript或兩者都難以導航這樣的迷宮?搜索機器人會在onclick事件中尋找/索引PHP代碼中的鏈接時遇到問題嗎?

下面的代碼,

<?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> 
+0

不要指望它:)。常規鏈接有什麼問題? – kapa

+0

鏈接在文本中 - 我認爲將它拉出是沒有問題的。它可能不瞭解確切的_relationship_(「鏈接到x的按鈕上的內容」),但這不是真正的搜索引擎如何工作。然而。 – Floris

+0

@kapa,沒什麼,我沒有解釋爲什麼我要這個,雖然,使用PHP更新div的單個頁面。 – pandoragami

回答

1
  1. 一般機器人不支持JavaScript,所以要避免,如果你想這些鏈接正確索引。爲什麼你甚至在那裏使用onClick?
  2. PHP沒有交付給客戶/機器人,只有它的輸出通常是HTML。只要你的輸出是有效的機器人應該爬行它就好了。
+0

我使用onclick啓動php模塊,如果你知道一個機器人搜索能夠顯示的方式。 – pandoragami

+0

@ user2555139你不是。我認爲你不會讓PHP運行在服務器上,而不是瀏覽器上。只需使用鏈接。 – Sammitch

+0

好的,然後回答它。所以機器人不遵循使用PHP生成html的onclick事件? – pandoragami

相關問題