锚标签表现怪异
Anchor Tag behaving weird
我的锚标签不工作,理想的 url 是 localhost/VShroff/home/about.php 然而 url 变成了 localhost/about.php 并且也没有重定向。很长一段时间以来,我一直在努力解决这个问题。
以下是HTML:
<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 & 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 & 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>
我正在使用以下 Jquery 和 CSS:
<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>
编辑:当我将鼠标悬停在 link 上时,它显示正确的 url (localhost/directories/about.php) 但是当我点击它时没有任何反应但浏览器 url 更改为 localhost/about.php (页面未重定向到 localhost/about.php)
我假设你的目录结构为
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>';
?>
它运行完美。
如果你在 www
目录中有这个 HTML 那么它会重定向到 localhost/about.php
。如果它出现在 www/shroff/home/
中,那么它将相对重定向到 localhsot/shroff/home/about.php
为什么不使用相对路径,例如:“./about.php”,如果您的关于页面与索引位于同一文件夹中...?
试试这个可能有用....
<?php
$root='http://'.$_SERVER['HTTP_HOST'].str_replace(basename($_SERVER['SCRIPT_NAME']), '', $_SERVER['SCRIPT_NAME']);
?>
<a href="<?php echo $root;?>/about.php">About</a>
JQuery 文件有蜂鸣导致此错误,无法细化并找出问题所在,但是在删除 jquery 文件后它正常工作。
我想我可以不用那个文件。
谢谢大家
我的锚标签不工作,理想的 url 是 localhost/VShroff/home/about.php 然而 url 变成了 localhost/about.php 并且也没有重定向。很长一段时间以来,我一直在努力解决这个问题。
以下是HTML:
<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 & 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 & 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>
我正在使用以下 Jquery 和 CSS:
<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>
编辑:当我将鼠标悬停在 link 上时,它显示正确的 url (localhost/directories/about.php) 但是当我点击它时没有任何反应但浏览器 url 更改为 localhost/about.php (页面未重定向到 localhost/about.php)
我假设你的目录结构为
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>';
?>
它运行完美。
如果你在 www
目录中有这个 HTML 那么它会重定向到 localhost/about.php
。如果它出现在 www/shroff/home/
中,那么它将相对重定向到 localhsot/shroff/home/about.php
为什么不使用相对路径,例如:“./about.php”,如果您的关于页面与索引位于同一文件夹中...?
试试这个可能有用....
<?php
$root='http://'.$_SERVER['HTTP_HOST'].str_replace(basename($_SERVER['SCRIPT_NAME']), '', $_SERVER['SCRIPT_NAME']);
?>
<a href="<?php echo $root;?>/about.php">About</a>
JQuery 文件有蜂鸣导致此错误,无法细化并找出问题所在,但是在删除 jquery 文件后它正常工作。
我想我可以不用那个文件。
谢谢大家