0

我正在尝试加载重定向到另一个页面的警报,但问题是页面的背景没有加载。唯一要呈现的 html 是 javascript 警报。知道如何解决这个问题,以便在警报之前至少加载一些 html 吗?

也试过

var onFooEndFunc = function() 
{
    var delay = 50; /* milliseconds - vary as desired */
    var executionTimer;

    return function() 
    {
        if (executionTimer) 
        {
            clearTimeout(executionTimer);
        }

        executionTimer = setTimeout(function() 
        {
            window.alert('Please download a game');
            window.location.href='games.html';
        }, delay);
    };
}();
4

2 回答 2

0

Popup is what you need

just set a div

<div id="popup_download">
  Please download a game!
    <a href="game1.exe">Mario</a>
     <a href="game2.exe">Sonice Rider</a>
</div>

at style set display:hidden

#popup_download
{
    position:absolute;
    display:none;
    top:200px;
    left:50%;
    width:500px; 
    margin-left:-250px;
    border:1px solid blue; 
    padding:20px;
    background-color:white;
}

when page is loaded just set display:block

<script type="text/javascript">
    function show_popup()
    {
      document.getElementById('popup_download').style.display = 'block'; 
    }

    window.onload = show_popup;
</script>

The benefit of it is you can add any HTML elements,css and even php or asp or any code inside and your background will continue working.

于 2013-04-21T01:47:46.527 回答
0

由于您使用 jQuery 进行了标记,因此您可以这样做:

$(document).ready(function(){
  window.alert('Please download a game')
  window.location.href='games.html';
});

或本机:

window.onload=function(){
  window.alert('Please download a game')
  window.location.href='games.html';
};
于 2013-04-21T01:11:18.827 回答