js第一次要双击才能触发事件,之后单击就行了

发布网友

我来回答

1个回答

热心网友

已demo,采纳即可

<!DOCTYPE HTML>
<html>
<head>
<meta charset=UTF-8 />
<title>Nothing</title>
<style type="text/css">
</style>
<script type="text/javascript" src="jquery-1.8.0.min.js"></script>
<script type="text/javascript">
onload = function ()
    {
    sendnews ();
    }
    
    function sendnews ()
    {
    var news = document.getElementsByName ('sendnews');
    for ( var i = 0; i < news.length; i++)
    {
    news[i].onclick = function ()
    {
    centerWindow ('send.php?id=' + this.title, (screen.width - 500) / 2, (screen.height - 350) / 2, 500,
            350, 'sendnews');
    };
    }
    }
    var popUpWin = 0;
    function centerWindow (URLStr, left, top, width, height, title)
    {
    if (popUpWin)
    {
    if (!popUpWin.closed)
    popUpWin.close ();
    }
    popUpWin = open (URLStr, title,
            'toolbar=no,location=no,directories=no,status=no,menub ar=no,scrollbar=no,resizable=no,copyhistory=yes,width='
                    + width + ',height=' + height + ',left=' + left + ', top=' + top + ',screenX=' + left
                    + ',screenY=' + top + '');
    }
</script>
</head>
<body>
<button name="sendnews">sendnews1</button>
<button name="sendnews">sendnews2</button>
<button name="sendnews">sendnews3</button>
</body>
</html>

声明声明:本网页内容为用户发布,旨在传播知识,不代表本网认同其观点,若有侵权等问题请及时与本网联系,我们将在第一时间删除处理。E-MAIL:11247931@qq.com