2016-06-08 68 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

也没有工作 –