2016-06-08 72 views
0

我的錨標記不工作,理想的網址是localhost/VShroff/home/about.php,但是URL更改爲localhost/about.php,並且也沒有重定向。自從很長一段時間以來,我一直在努力解決這個問題。Anchor Tag behaviour怪異

以下是HTML:使用下面的jQuery和CSS

<html> 
    <head> 
    <meta name="generator" 
    content="HTML Tidy for HTML5 (experimental) for Windows https://github.com/w3c/tidy-html5/tree/c63cc39" /> 
    <title></title> 
    </head> 
    <body> 
    <div class="row" style="margin:10px;"> 
     <div id="blocka" class="column col-md-6" style="padding:20px;width:150px;height:150px;background-color:#DA0A82"> 
     <ul> 
      <li> 
      <a style="font-family:perpetua;font-size:16px;color:white;" href="about.php">About</a> 
      </li> 
      <li id="family" class="family" style="font-family:perpetua;font-size:16px;color:white;">Family</li> 
      <li id="ent" class="ent" style="font-family:perpetua;font-size:16px;color:white;">Enterprise</li> 
      <li style="font-family:perpetua;font-size:16px;color:white;">News &amp; Media</li> 
      <li style="font-family:perpetua;font-size:16px;color:white;">Resources</li> 
     </ul> 
     </div> 
     <div id="familyNav" class="familyNav column col-md-6" 
     style="margin-left:10px;padding:20px;width:150px;height:150px;background-color:#7D0651"> 
     <ul> 
      <li style="font-family:perpetua;font-size:16px;color:white;">Timeline</li> 
      <li style="font-family:perpetua;font-size:16px;color:white;">Tree</li> 
      <li style="font-family:perpetua;font-size:16px;color:white;">Biographies</li> 
     </ul> 
     </div> 
     <div id="enterprise" class="enterprise column col-md-6" 
     style="margin-left:10px;padding:20px;width:150px;height:150px;background-color:#7D0651"> 
     <ul> 
      <li style="font-family:perpetua;font-size:16px;color:white;">Parimal K. Shroff &amp; Co.</li> 
      <li style="font-family:perpetua;font-size:16px;color:white;">Sunways Group</li> 
      <li style="font-family:perpetua;font-size:16px;color:white;">Organograms</li> 
      <li style="font-family:perpetua;font-size:16px;color:white;">The Shroffice</li> 
     </ul> 
     </div> 
    </div> 
    </body> 
</html> 

林:

<script> 
$('.family').click(function() { 
    $('#enterprise').hide(); 
    $('#familyNav').slideToggle('2000',"swing", function() { 
     // Animation complete. 
    }); 
}); 
$('.ent').click(function() { 
    $('#familyNav').hide(); 
    $('#enterprise').slideToggle('2000',"swing", function() { 
     // Animation complete. 
    }); 
}); 
</script> 

<style> 
#blocka { 
    z-index: 100; 
} 
#familyNav { 
    display:none; 
} 
#family { 
    cursor:pointer; 
} 
#enterprise { 
    display: none; 
} 
#ent { 
    cursor: pointer; 
} 
</style> 

編輯:當我將鼠標懸停我的鼠標在鏈接上,它顯示了正確的URL(本地主機/directories/about.php)然而,當我點擊它時,沒有任何反應,但瀏覽器的網址變成了localhost/about.php(該頁面沒有被重定向到localhost/about.php)

+0

可能你有''標籤嗎? – Midas

+0

關於菜單定位標記不工作或其他菜單? – Mani

+0

沒有標籤正在工作。而且我沒有任何基礎href –

回答

0

jQuery的文件已BEEB造成這個錯誤,無法細化,並找出是什麼問題,但在刪除它工作正常jQuery的文件。

我想我可以沒有這個文件。

謝謝大家。

0

I assu我你的目錄結構爲

htdocs or www (BASED ON YOUR SERVER) 
| 
|--Vshroff 
     |--NEW 
      |--home 
      | 
      |-index.php(HERE IS THE ANCHOR TAG) 
      |-about.php 

所以我在我的機器上創建了相同的結構。 以下是文件

的index.php

<?php 
echo '<a href="about.php">about</a>'; 
?> 

about.php

<?php 
echo '<a href="index.php">index</a>'; 
?> 

它它的作品完美。

+0

鑑於描述,這將是另一種方式.. – GolezTrol

+0

它是好的@GolezTrol?請糾正我,如果我錯了.. –

+0

告訴我們這個HTML代碼存在的目錄結構。 – Himanshu

0

如果您在www目錄中有此HTML,那麼它將重定向到localhost/about.php。如果它出現在www/shroff/home/那麼它將相對重定向到localhsot/shroff/home/about.php

+0

不是代碼不在www目錄中。 –

+0

我想你提供的代碼和'about.php'在同一個文件夾中。如果是這種情況,那麼它應該正常工作。 – Himanshu

+0

我提供的代碼是在同一個文件夾中,不工作但 –

0

爲什麼不使用相對路徑如:「./about.php」,如果你的關於頁面與索引位於同一文件夾...?

+0

不工作 –

+0

你試過你的網頁沒有你的JavaScript代碼? (只是評論它,然後再試一次) – Julo0sS

+0

是的,如果沒有JavaScript,也不行。 –

0

試試這個它可能工作....

<?php 
    $root='http://'.$_SERVER['HTTP_HOST'].str_replace(basename($_SERVER['SCRIPT_NAME']), '', $_SERVER['SCRIPT_NAME']); 
?> 
<a href="<?php echo $root;?>/about.php">About</a> 
+0

也沒有工作 –