1

我正在尝试在我的网站内插入一个显示登录信息的滑块...这必须动态加载...这就是我所做的

 <!DOCTYPE html>
<html lang="en">
<head>
<title>Home</title>
<meta charset="utf-8">
<link rel="stylesheet" href="css/reset.css" type="text/css" media="all">
<link rel="stylesheet" href="css/layout.css" type="text/css" media="all">
<link rel="stylesheet" href="css/style.css" type="text/css" media="all">

<!--<script type="text/javascript" src="js/jquery-1.4.2.js" ></script>-->
<script type="text/javascript" src="js/cufon-yui.js"></script>
<script type="text/javascript" src="js/cufon-replace.js"></script>
<script type="text/javascript" src="js/Myriad_Pro_400.font.js"></script>
<script type="text/javascript" src="js/Myriad_Pro_700.font.js"></script>
<script type="text/javascript" src="js/Myriad_Pro_600.font.js"></script>
<!--<script src="js/jquery-1.3.2.min.js" type="text/javascript"></script>-->
    <!-- Sliding effect -->


<script type="text/javascript">

/***********************************************
* Dynamic Ajax Content- © Dynamic Drive DHTML code library (www.dynamicdrive.com)
* This notice MUST stay intact for legal use
* Visit Dynamic Drive at http://www.dynamicdrive.com/ for full source code
***********************************************/

var bustcachevar=1 //bust potential caching of external pages after initial request? (1=yes, 0=no)
var loadedobjects=""
var rootdomain="http://"+window.location.hostname
var bustcacheparameter=""

function ajaxpage(url, containerid){
var page_request = false
if (window.XMLHttpRequest) // if Mozilla, Safari etc
page_request = new XMLHttpRequest()
else if (window.ActiveXObject){ // if IE
try {
page_request = new ActiveXObject("Msxml2.XMLHTTP")
} 
catch (e){
try{
page_request = new ActiveXObject("Microsoft.XMLHTTP")
}
catch (e){}
}
}
else
return false
page_request.onreadystatechange=function(){
loadpage(page_request, containerid)
}
if (bustcachevar) //if bust caching of external page
bustcacheparameter=(url.indexOf("?")!=-1)? "&"+new Date().getTime() : "?"+new Date().getTime()
page_request.open('GET', url+bustcacheparameter, true)
page_request.send(null)
}

function loadpage(page_request, containerid){
if (page_request.readyState == 4 && (page_request.status==200 || window.location.href.indexOf("http")==-1))
document.getElementById(containerid).innerHTML=page_request.responseText
}

function loadobjs(){
if (!document.getElementById)
return
for (i=0; i<arguments.length; i++){
var file=arguments[i]
var fileref=""
if (loadedobjects.indexOf(file)==-1){ //Check to see if this object has not already been added to page before proceeding
if (file.indexOf(".js")!=-1){ //If object is a js file
fileref=document.createElement('script')
fileref.setAttribute("type","text/javascript");
fileref.setAttribute("src", file);
}
else if (file.indexOf(".css")!=-1){ //If object is a css file
fileref=document.createElement("link")
fileref.setAttribute("rel", "stylesheet");
fileref.setAttribute("type", "text/css");
fileref.setAttribute("href", file);
}
}
if (fileref!=""){
document.getElementsByTagName("head").item(0).appendChild(fileref)
loadedobjects+=file+" " //Remember this object as being already added to page
}
}
}

</script>

<!--[if lt IE 9]>
    <script type="text/javascript" src="http://info.template-help.com/files/ie6_warning/ie6_script_other.js"></script>
    <script type="text/javascript" src="js/html5.js"></script>
<![endif]-->
</head>
<body id="page1">
<div class="main">
<!-- header -->
    <header>
        <div class="wrapper">
         <!-- Panel -->

<div id="toppanel">
    <script type="text/javascript">
    ajaxpage('login.php', 'toppanel');
    </script>
  <!--  <a href="javascript:ajaxpage('login.php', 'toppanel');">test</a>-->
</div> 

我的动态加载 login.php 是

<script type="text/javascript" src="js/jquery-1.4.2.js" ></script>
<script src="js/jquery-1.7.2.min.js" type="text/javascript"></script>
<script src="js/slide.js" type="text/javascript"></script>


<script type="text/javascript">
document.write(unescape('%3Cscript src="js/jquery-1.4.2.js"%3E%3C/script%3E'));
document.write(unescape('%3Cscript src="js/jquery-1.3.2.min.js"%3E%3C/script%3E'));

$(document).ready(function() {
        // Expand Panel
        $("#open").live('click',function(){
//  $("#open").click(function(){
        $("#panel").slideDown("slow");

    }); 

    // Collapse Panel
    $("#close").click(function(){
        $("div#panel").slideUp("slow"); 
    });     

    // Switch buttons from "Log In | Register" to "Close Panel" on click
    $("#toggle a").click(function () {
        $("#toggle a").toggle();
    });     

});
</script>   
<?php

session_start(); 
include('includes/utility_functions.php');
installationCheck();
$errorMessage = '';
if (isset($_SESSION["loginError"]) && !empty($_SESSION["loginError"])) {
    $errorMessage = $_SESSION["loginError"];
    $_SESSION["loginError"]='';  //clear the error so as not show again unless there is a new error
}

if (isset($_SESSION["username"]) && !empty($_SESSION["username"])) {
    $username = $_SESSION["username"];
    }
else { $username = "Guest"; }
//echo $_SESSION["loginError"];
?>

<div id="panel">
        <div class="content clearfix">
            <div class="left">
                <h1>poda patto</h1>
                <h2>Sliding login panel Demo with jQuery</h2>       
                <p class="grey">You can put anything you want in this sliding panel: videos, audio, images, forms... The only limit is your imagination!</p>
                <h2>Download</h2>
                <p class="grey">To download this script go back to <a href="http://web-kreation.com/index.php/tutorials/nice-clean-sliding-login-panel-built-with-jquery" title="Download">article &raquo;</a></p>
            </div>
            <div class="left">
                <!-- Login Form -->
                <form class="clearfix" action="doLogin.php" method="post">
                    <h1>Member Login</h1>
                    <label class="grey" for="log">Username:</label>
                    <input class="field" type="text" name="username" id="username" value="" size="23" />
                    <label class="grey" for="pwd">Password:</label>
                    <input class="field" type="password" name="password" id="password" size="23" />
                    <label><input name="rememberme" id="rememberme" type="checkbox" checked="checked" value="forever" /> &nbsp;Remember me</label>
                    <div class="clear"></div>
                    <input type="submit" name="submit" value="Login" class="bt_login" />
                    <a class="lost-pwd" href="#">Lost your password?</a>
                </form>
            </div>
            <div class="left right">            
                <!-- Register Form -->
                <form action="doRegistration.php" method="post">
                    <h1>Not a member yet? Sign Up!</h1>             
                    <label class="grey" for="signup">Username:</label>
                    <input class="field" type="text" name="signup" id="signup" value="" size="23" />
                    <label class="grey" for="email">Email:</label>
                    <input class="field" type="text" name="email" id="email" size="23" />
                    <label for="regPassword">Password:</label>
                  <input class="field" id="password" name="password" type="password" size="23" />
                <label for="verifyPassword">Verify Password:</label>
                <input class="field" id="verifyPassword" name="verifyPassword" type="password" size="25" />
                    <input type="submit" name="submit" value="Register" class="bt_register" />
                </form>
            </div>
        </div>
</div> <!-- /login -->  

    <!-- The tab on top --> 
    <div class="tab">
        <ul class="login">
            <li class="left">&nbsp;</li>
            <li>Hello <?php echo $username; ?> </li>
            <li class="sep">|</li>
            <li id="toggle">
                <a id="open" class="open" href="#">Log In | Register</a>
                <a id="close" style="display: none;" class="close" href="#">Close Panel</a>         </li>
            <li class="right">&nbsp;</li>
        </ul> 
    </div> <!-- / top -->

我的问题是 innerhtml 正在显示,但是用于向下滑动面板 div 的 jquery 功能不起作用

4

0 回答 0