希望有人能帮助我解决我遇到的问题。从另一个页面调用幻灯片功能时,我无法在下拉表单上运行它。
我有一个 admin.php 页面,其中包含一个 isAdmin.php 文件来检查用户是否是管理员用户。如果没有,它会将它们重定向到index.php 页面。然后我想调用我的幻灯片函数,以便登录表单向下滑动到 View 中,但该命令不起作用。
代码是..
是管理员:
if(!isAdmin())
{
header('Location: ../index.php?status=3');
//Login page should slide down for user to see the status message but function is not working correctly
echo '<script> $(document).ready(function (){ $("div#panel").slideDown("slow"); });</script> ';
}
单击登录表单选项卡时,这是运行的函数(效果很好):
$(function() {
$("#login").click(function(e) {
//e.preventDefault(); - Stops the page scrolling to the top
$("div#panel").slideDown("slow");
$("#toggle a").toggle();
});
});
最佳答案
(如果我理解的话)。重定向后删除 echo
:
if(!isAdmin()) {
header('Location: ../index.php?status=3');
//Login page should slide down for user to see the status message but
exit;
}
更改“index.php”:
<?php if ( (isset($_GET['status']) && ($_GET['status']=='3')):?>
<script> $(document).ready(function (){ $("div#panel").slideDown("slow"); });</script>
<? endif;?>
关于Javascript无法运行表单的幻灯片效果,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21056452/