每次我点击我的网站,它会重定向到home.html然后回到我点击的所需网址

时间:2015-02-17 10:04:44

标签: javascript html

正如标题所暗示的那样。我的网站遇到了麻烦。当我点击一个链接时,我会让我的home.html出现。然后它将转到所需的链接。它只有几秒钟。然而,当我试图备份我已经完成的搜索时,它真的很烦人。我的index.html代码如下。

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en">
<head>
    <title>M3TA4.NET</title>
    <meta http-equiv="content-type" content="text/html;charset=utf-8" />
    <meta name="description" content="M3TA4.NET"/>
    <meta name="keywords" content="M3TA4.NET, m3ta4, m3ta4dotnet, m3ta4.com, m3ta4dotcom, sir0m3ta4, 3d objects, homepage, help, wallpapers, backgrounds, 3d, blender models, blender3d models, models, free software, software,"/>
    <link rel="shortcut icon" href="micon.ico" type="image/x-icon" />
    <link rel="icon" href="micon.ico" type="image/ico" />

    <style type="text/css">
        * {
            padding:0;
            margin:0;
        }
    html, body {
        width:100%;
        height:100%;
        overflow:hidden;
        margin:0;
        padding:0;
        background:#000;
    }
    #hdr {
        position:absolute;
        display:block;
        background:#fff;
        top:0;
        left:0;
        right:0;
        height:60px;
        width:100%;
        overflow:hidden;
        text-align:center;
    }
    #hdr_btns {
        width:875px;
        margin:0 auto;
    }
    #hdr_btns img {
        height:40px;
    }
    #middle {
        position:absolute;
        display:block;
        background:#fff;
        top:60px;
        left:0;
        bottom:60px;
        height:auto;
        right:0;
        width:100%;
        overflow:auto;
    }
    #middle iframe {
            width:100%;
            height:100%;
            position:relative;
            background:#fff;
            border:0;
        }
    #ftr {
        overflow:hidden;
        display:block;
        background:#fff;
        position:absolute;
        top:auto;
        left:0;
        bottom:0;
        height:60px;
        width:100%;
    }
    #ftr_btns {
        width:640px;
        margin:0 auto;
    }
    .btns {
            display:block;
            float:left;
            margin-left:0px;
            margin-top:0px;
            background:#fff;
        }
        input {
            border:0px solid #fff;
        }
        #logo {
            position:absolute;
            display:block;
            right:10px;
            bottom:26px;
            left:auto;
            top:auto;
            width:200px;
            height:auto;            
        }
        #logo img {
            width:200px;
        }

        @media (min-width: 1300px) {

            #hdr_btns {
                width:1300px;
            }

            #hdr_btns img {
                height:60px;
            }

        }

    </style>
    <script type="text/javascript">
        function clk(url){

            document.getElementById('content').src=url;

        };
        function loadsource(){
            var defaultPage = "home.html";
            var query = window.location.search.substring(1);
            var pos = query.indexOf('=');
            if (pos > 0){
                var frameSource = query.substring(pos+1);
                //window.frames["content"].location = frameSource;
                document.getElementById('content').src= frameSource;

            }else{
                //window.frames["content"].location = defaultPage;
                document.getElementById('content').src= defaultPage;
            }
        };
    </script>


</head>
<body onload="loadsource()">
    <div id="hdr">
        <div id="hdr_btns">
            <div class="btns"><a href="http://m3ta4.net/index.html?page=3dobjects.html"><img src="linkz/3dobjectzon.png" onmouseover="this.src='linkz/3dobjectzoff.png'" onmouseout="this.src='linkz/3dobjectzon.png'" onclick="this.src='linkz/3dobjectzclick.png'" border="0" alt="3d objects page"/></a></div>
            <div class="btns"><a href="http://m3ta4.net/index.html?page=software.html"><img src="linkz/freesoftwareon.png" onmouseover="this.src='linkz/freesoftwareoff.png'" onmouseout="this.src='linkz/freesoftwareon.png'" onclick="this.src='linkz/freesoftwareclick.png'" border="0" alt="free software page"/></a></div>
            <div class="btns"><a href="http://m3ta4.net/index.html?page=helpdesk.html"><img src="linkz/helpdeskon.png" onmouseover="this.src='linkz/helpdeskoff.png'" onmouseout="this.src='linkz/helpdeskon.png'" onclick="this.src='linkz/helpdeskclick.png'" border="0" alt="free software page"/></a></div>
            <div class="btns"><a href="http://m3ta4.net/index.html?page=reviews/reviews.html"><img src="linkz/reviewzon.png" onmouseover="this.src='linkz/reviewzoff.png'" onmouseout="this.src='linkz/reviewzon.png'" onclick="this.src='linkz/reviewzclick.png'" border="0" alt="free software page"/></a></div>
            <div class="btns"><a href="http://m3ta4.net/index.html?page=wallpapers.html"><img src="linkz/freewallpaperon.png" onmouseover="this.src='linkz/freewallpaperoff.png'" onmouseout="this.src='linkz/freewallpaperon.png'" onclick="this.src='linkz/freewallpaperclick.png'" border="0" alt="free software page"/></a></div>

        </div>
    </div>

    <div id="middle" >
        <iframe id="content" name="content" src="home.html" border="0"></iframe>
    </div>
    <div id="ftr" >

        <div id="ftr_btns">
            <div class="btns"><a href="http://www.facebook.com/pages/M3TA4NET/249868325065235" target="blank"><img src="http://www.m3ta4.net/linkz/facebook.png" onmouseover="this.src='http://www.m3ta4.net/linkz/facebook.gif'" onmouseout="this.src='http://www.m3ta4.net/linkz/facebook.png'" height="60px"border="0" alt="Facebook.com link"/></a></div>
            <div class="btns"><a href="http://www.youtube.com/metaphor26" target="blank"><img src="http://www.m3ta4.net/linkz/youtube.png" onmouseover="this.src='http://www.m3ta4.net/linkz/youtube.gif'" onmouseout="this.src='http://www.m3ta4.net/linkz/youtube.png'" height="60px" border="0" alt="Youtube.com link"/></a></div>
            <div class="btns"><a href="http://www.gmail.com/" target="blank"><img src="http://www.m3ta4.net/linkz/gmail.png" onmouseover="this.src='http://www.m3ta4.net/linkz/gmail.gif'" onmouseout="this.src='http://www.m3ta4.net/linkz/gmail.png'" height="60px" border="0" alt="Gmail.com link"/></a></div>
            <div class="btns"><a href="http://www.mail.com" target="blank"><img src="http://www.m3ta4.net/linkz/mail.png" onmouseover="this.src='http://www.m3ta4.net/linkz/mail.gif'" onmouseout="this.src='http://www.m3ta4.net/linkz/mail.png'" height="60px" border="0" alt="Mail.com link"/></a></div>
            <div class="btns"><a href="http://www.blender.org/" target="blank"><img src="http://www.m3ta4.net/linkz/blender.png" onmouseover="this.src='http://m3ta4.net/linkz/blender.gif'" onmouseout="this.src='http://www.m3ta4.net/linkz/blender.png'" height="60px" border="0" alt="blender.org link"/></a></div>
            <div class="btns"><a href="http://www.ubuntu.com/" target="blank"><img src="http://www.m3ta4.net/linkz/ubuntu.png" onmouseover="this.src='http://www.m3ta4.net/linkz/ubuntu.gif'" onmouseout="this.src='http://www.m3ta4.net/linkz/ubuntu.png'" height="60px" border="0" alt="ubuntu.com link"/></a></div>
            <div class="btns"><a href="http://www.gumtree.com.au" target="blank"><img src="http://www.m3ta4.net/linkz/gumtree.png" onmouseover="this.src='http://m3ta4.net/linkz/gumtree.gif'" onmouseout="this.src='http://www.m3ta4.net/linkz/gumtree.png'" height="60px" border="0" alt="Gumtree.com.au link"/></a></div>
            <div class="btns"><a href="http://www.ebay.com.au" target="blank"><img src="http://www.m3ta4.net/linkz/ebay.png" onmouseover="this.src='http://www.m3ta4.net/linkz/ebay.gif'" onmouseout="this.src='http://www.m3ta4.net/linkz/ebay.png'" height="60px" border="0" alt="Ebay.com link"/></a></div>
            <div class="btns"><a href="http://www.rewardscentral.com.au/Join/Default.aspx?refer=dru_b" target="blank"><img src="http://www.m3ta4.net/linkz/rewardscentral.png" onmouseover="this.src='http://www.m3ta4.net/linkz/rewardscentral.gif'" onmouseout="this.src='http://www.m3ta4.net/linkz/rewardscentral.png'" height="60px" border="0" alt="Rewardscentral link"/></a></div>


        </div>
    </div>

    <a id="logo" href="home.html" target="content"><img src="m3ta4-logo.png" alt="logo" border="0"/></a>
</body> 
</html>

我还上传了一个YouTube视频来展示正在发生的事情。 video of the issue(注意youtube视频已被删除。)

如果您需要更多信息,我很乐意将其提供给您。 还要注意我对网页编码很新。

1 个答案:

答案 0 :(得分:0)

src元素中删除iframe属性:

<iframe id="content" name="content" border="0"></iframe>

目前,当您点击链接时,它会重新加载页面。您的loadSource功能在页面加载之前不会被触发。这意味着页面首先呈现,iframe已加载home.htmliframe。然后loadSource被触发,然后根据点击的链接更改iframe的内容。