8月 19

主页面的代码

<script language="javascript" type="text/javascript">

function Button1_onclick()
{
    window.open("HTMLPage2.htm");
   
}
function Test(s)
{
    alert(s);
}

</script>
</head>
<body>

    <p>
        <input id="Button1" type="button" value="button" onclick="return Button1_onclick()" />&nbsp;&nbsp;&nbsp;&nbsp;
    </p>

</body>

弹出的页面调用来源页面的函数

function Button1_onclick()
{
    window.opener.Test("111");
    window.close();
}

</script>
</head>
<body>
    <input id="Button1" type="button" value="button" onclick="Button1_onclick()" />
</body>

written by ocean

8月 19

function mousePosition(ev) {
        //支持 火狐
        if (ev.pageX || ev.pageY) {
            return { x: ev.pageX, y: ev.pageY };
        }
        //支持IE
        return {
            x: ev.clientX + document.body.scrollLeft – document.body.clientLeft,
            y: ev.clientY + document.body.scrollTop – document.body.clientTop
        };
    }

    function mouseMove(ev) {
        ev = ev || window.event;
        var mousePos = mousePosition(ev);

        document.getElementById('div1').innerHTML = 'location: ' + mousePos.x + "*" + mousePos.y;
        document.getElementById('div1').style.left = mousePos.x + 5;
        document.getElementById('div1').style.top = mousePos.y + 0;
    }

    //事件添加
    document.onmousemove = mouseMove;

兼容火狐和IE

written by ocean