1

我试图在我的页面上安装一个基于 Flash 的音乐播放器,即使您刷新或转到网站内的另一个页面,它也会继续播放歌曲。

我想像 facebook 页脚那样做

我阅读了这个主题 Facebook 如何在加载不同页面时保持页眉和页脚固定?

但我有 loadpage() 和 location.hash 问题

如果有人知道它是如何制作的请告诉我

4

2 回答 2

2
var header = document.getElementById('header');
var headerLinks = header.getElementsByTagName('a');
for(var i = 0, l = headerLinks.length; i < l; i++) 
{ 
 headerLinks[i].onclick = function() {    
var href = this.href;   
 //Load the AJAX page (this is a whole other topic)    
loadPage(href);      
//Update the address bar to make it look like you were redirected   
 location.hash = '#' + href;    
//Unfocus the link to make it look like you were redirected    
this.blur();   
 //Prevent the natural HTTP redirect    
return false;  

}}

CSS:

#Footer  {  
font-size:xx-small;   
text-align:left;   
width:100%;   
bottom:0px;   
position:fixed;   
left:0px;   
background-color: #CCCCCC;   
border-top: 1px solid #999999;   
padding:4px;   
padding-right:20px;   
color:#666666; 
}

我已经这样做了,所以这段代码不起作用,我不想刷新音乐播放器的区域,比如谷歌视频或 Facebook 任务栏

我已经这样做了

function links() {
    //var header = document.getElementById("header");
    var headerLinks = document.getElementsByTagName("a");
    for (var i = 0, l = headerLinks.length; i < l; i++) {
        headerLinks[i].onclick = function() {
            var href = this.href;
            loadPage(href);
            window.location.hash = "#" + href;
            this.blur();
           return false;
        }
    }
}

window.onload = function() {
    links();
}

我想修改所有链接,但它不起作用

于 2009-07-27T09:56:58.483 回答
1

It looks like you are pretty new to javascript. If that is the case then doing a full ajax site is probably not the place to start. I think you should try going old-school and using frames to accomplish this. (This is how Google Video used to function, and Google Images still uses this technique.)

<html>
    <frameset rows="200px,*,200px">
        <frame src="yourPageHeaderWithFlashPlayer.html" noresize="noresize"/>
        <frame src="yourMainContent.html" noresize="noresize"/>
        <frame src="yourPageFooter.html" noresize="noresize"/>
    </frameset>
</html>

That would work for a 200px header and 200px footer. If you need more info: http://www.w3schools.com/tags/tag_frameset.asp.

于 2009-07-27T13:58:04.270 回答