0

我有一个加载外部 php 文件的主 php 文件。这是我的主 php 文件中的代码:

<php>
<head>
    <meta http-equiv="content-type" content="text/php; charset=utf-8" />
    <link rel="stylesheet" type="text/css" media="all" href="style.css" />


    <script type="text/javascript" src="ajax.js"></script>
    <link rel="stylesheet" href="colorbox.css" />

        <script src="js/jquery.colorbox.js"></script>
        <script src="js/jquery-1.8.2.min.js"></script>
        <script src="js/jquery.colorbox-min.js"></script>

<link href="jimgMenukwicks.css" rel="stylesheet" type="text/css" />

<script type="text/javascript" src="js/jquery-easing-1.3.pack.js"></script>
<script type="text/javascript" src="js/jquery-easing-compatibility.1.2.pack.js"></script>
<script type="text/javascript" src="js/jquery.kwicks-1.5.1.pack.js"></script>       

    <script type="text/javascript">
      $().ready(function() {
    $('.jimgMenu ul').kwicks({max: 310, duration: 300, easing: 'easeOutQuad'});
    });
</script>


</head>


<div id="tengah" class="jimgMenu" >

  <ul>
    <li class="landscapes"> <a href="javascript:ajaxpage('7.php', 'ResponseDiv');"> </a></li>
    <li class="people"> <a href="javascript:ajaxpage('8.php', 'ResponseDiv');"> </a></li>
    <li class="nature"> <a href="javascript:ajaxpage('9.php', 'ResponseDiv');"> </a></li>
  </ul>

</div>
    <div id="content" class="clearfix shadow">
        <div id="sidebar" class="left">

<div id='ResponseDiv'> </div>
            <div id="menu" class="inner">

            </div>
        </div>

        <div id="main" class="right">
        <h2>Detail</h2>

        <div id='ResponseDiv2'> </div>

        </div>
    </div>
</div>

</php>

我有一个函数ajax.js调用一个名为ajaxpage. 这里的代码ajax.js

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)
    }
    page_request.open('GET', url, 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
}

问题是当我尝试将“7.php”加载到我的 main.php 中时,7.php 文件已加载,但 7.php 中的动画不起作用。

有谁知道为什么会这样?

这是7.php的内容

<php>
<html>
<head>
<style type="text/css">
body {
    background: #0F0D0D;
    padding: 30px 0 0 50px;
}
div.sc_menu_wrapper {
    position: relative;     
    height: 500px;
    /* Make bigger than a photo, because we need a place for a scrollbar. */
    width: 160px;

    margin-top: 30px;
    overflow: auto;
}
div.sc_menu {
    padding: 15px 0;
}
.sc_menu a {
    display: block;
    margin-bottom: 5px;
    width: 130px;

    border: 2px rgb(79, 79, 79) solid;
    -webkit-border-radius: 4px;
    -moz-border-radius: 4px;        

    /* When image support is turned off */
    color: #fff;
    background: rgb(79, 79, 79);    
}
.sc_menu a:hover {
    border-color: rgb(130, 130, 130);
    border-style: dotted;
}
.sc_menu img {
    display: block;
    border: none;
}

.sc_menu_wrapper .loading {
    position: absolute;
    top: 50px;
    left: 10px;

    margin: 0 auto;
    padding: 10px;

    width: 100px;
    -webkit-border-radius: 4px;
    -moz-border-radius: 4px;    

    text-align: center;
    color: #fff;
    border: 1px solid rgb(79, 79, 79);
    background: #1F1D1D;
}
/* Styling tooltip */
.sc_menu_tooltip {
    display: block;
    position: absolute;

    padding: 6px;
    font-size: 12px;    
    color: #fff;

    -webkit-border-radius: 4px;
    -moz-border-radius: 4px;    

    border: 1px solid rgb(79, 79, 79);
    background: rgb(0, 0, 0);
    /* Make background a bit transparent for browsers that support rgba */  
    background: rgba(0, 0, 0, 0.5);
}

/* Here are styles for a link to an article. Not for you :) */
#back {
    margin-left: 8px;
    color: gray;
    font-size: 18px;
    text-decoration: none;
}
#back:hover {
    text-decoration: underline;
}
</style>
<script src="js/jquery.js" type="text/javascript"></script>
<script type="text/javascript">/*<![CDATA[*/

function makeScrollable(wrapper, scrollable){
    // Get jQuery elements
    var wrapper = $(wrapper), scrollable = $(scrollable);

    // Hide images until they are not loaded
    scrollable.hide();
    var loading = $('<div class="loading">Loading...</div>').appendTo(wrapper);

    // Set function that will check if all images are loaded
    var interval = setInterval(function(){
        var images = scrollable.find('img');
        var completed = 0;

        // Counts number of images that are succesfully loaded
        images.each(function(){
            if (this.complete) completed++; 
        });

        if (completed == images.length){
            clearInterval(interval);
            // Timeout added to fix problem with Chrome
            setTimeout(function(){

                loading.hide();
                // Remove scrollbars    
                wrapper.css({overflow: 'hidden'});                      

                scrollable.slideDown('slow', function(){
                    enable();   
                });                 
            }, 1000);   
        }
    }, 100);

    function enable(){
        // height of area at the top at bottom, that don't respond to mousemove
        var inactiveMargin = 99;                    
        // Cache for performance
        var wrapperWidth = wrapper.width();
        var wrapperHeight = wrapper.height();
        // Using outer height to include padding too
        var scrollableHeight = scrollable.outerHeight() + 2*inactiveMargin;
        // Do not cache wrapperOffset, because it can change when user resizes window
        // We could use onresize event, but it's just not worth doing that 
        // var wrapperOffset = wrapper.offset();

        // Create a invisible tooltip
        var tooltip = $('<div class="sc_menu_tooltip"></div>')
            .css('opacity', 0)
            .appendTo(wrapper);

        // Save menu titles
        scrollable.find('a').each(function(){               
            $(this).data('tooltipText', this.title);                
        });

        // Remove default tooltip
        scrollable.find('a').removeAttr('title');       
        // Remove default tooltip in IE
        scrollable.find('img').removeAttr('alt');   

        var lastTarget;
        //When user move mouse over menu            
        wrapper.mousemove(function(e){
            // Save target
            lastTarget = e.target;

            var wrapperOffset = wrapper.offset();

            var tooltipLeft = e.pageX - wrapperOffset.left;
            // Do not let tooltip to move out of menu.
            // Because overflow is set to hidden, we will not be able too see it 
            tooltipLeft = Math.min(tooltipLeft, wrapperWidth - 75); //tooltip.outerWidth());

            var tooltipTop = e.pageY - wrapperOffset.top + wrapper.scrollTop() - 40;
            // Move tooltip under the mouse when we are in the higher part of the menu
            if (e.pageY - wrapperOffset.top < wrapperHeight/2){
                tooltipTop += 80;
            }               
            tooltip.css({top: tooltipTop, left: tooltipLeft});              

            // Scroll menu
            var top = (e.pageY -  wrapperOffset.top) * (scrollableHeight - wrapperHeight) / wrapperHeight - inactiveMargin;
            if (top < 0){
                top = 0;
            }           
            wrapper.scrollTop(top);
        });

        // Setting interval helps solving perfomance problems in IE
        var interval = setInterval(function(){
            if (!lastTarget) return;    

            var currentText = tooltip.text();

            if (lastTarget.nodeName == 'IMG'){                  
                // We've attached data to a link, not image
                var newText = $(lastTarget).parent().data('tooltipText');

                // Show tooltip with the new text
                if (currentText != newText) {
                    tooltip
                        .stop(true)
                        .css('opacity', 0)  
                        .text(newText)
                        .animate({opacity: 1}, 1000);
                }                   
            }
        }, 200);

        // Hide tooltip when leaving menu
        wrapper.mouseleave(function(){
            lastTarget = false;
            tooltip.stop(true).css('opacity', 0).text('');
        });         

        /*
        //Usage of hover event resulted in performance problems
        scrollable.find('a').hover(function(){
            tooltip
                .stop()
                .css('opacity', 0)
                .text($(this).data('tooltipText'))
                .animate({opacity: 1}, 1000);

        }, function(){
            tooltip
                .stop()
                .animate({opacity: 0}, 300);
        });
        */          
    }
}

$(function(){   
    makeScrollable("div.sc_menu_wrapper", "div.sc_menu");
});


</script>
</head>
<body>
<div style="overflow: hidden;" class="sc_menu_wrapper">
    <div style="display: block;" class="sc_menu">
        <a href="#" ><img src="images/1.jpg"></a>
        <a href="#" ><img src="images/2.jpg"></a>
        <a href="#" ><img src="images/3.jpg"></a>       
        <a href="#" ><img src="images/4.jpg"></a>
        <a href="#" ><img src="images/5.jpg"></a>
        <a href="#" ><img src="images/6.jpg"></a>

    </div>
<div style="display: none;" class="loading">Loading...</div><div style="opacity: 0;" class="sc_menu_tooltip"></div></div>

</body></html>
</php>
4

1 回答 1

0
<a href="#" onmouseover="javascript:ajaxpage('ajaxfiles/hotel.html', 'rightcolumn'); loadobjs('css/style.css', 'css/slide.css', 'js/jquery1.3.2-min.js', 'js/jquery-ui1.5.3-min.js', 'js/featured.js')">See Hotel</a>

此代码将工作...

于 2013-02-02T11:15:31.970 回答