js窗口移动操作

本文介绍了一个使用JavaScript实现的窗口移动函数moveWin(),该函数可以使得窗口在屏幕上下左右进行循环移动。通过window.open()创建新窗口,并设置窗口位置,然后利用document.write()写入内容。
摘要由CSDN通过智能技术生成
<script type="text/javascript">
var timer1 = null;
var timer2 = null;
var timer3 = null;
var timer4 = null;

function moveWin()
{
//打开一个新窗口
//_blank - URL加载到一个新的窗口。这是默认
myWindow=window.open(’’,’ 这是一个跳动窗口’,‘width=300,height=300,top=200,left=750’);
myWindow.document.write(“

此窗口进行上下左右循环移动!

”);
var up = function(){
//向上跳动
var count1 = 2;
timer1 = setInterval(function(){
count1 --;
myWindow.moveBy(0,-50);
myWindow.focus();
console.log(“count1=” + count1);
if(count1 0){
clearInterval(timer1);
}else {count1++}},5000);
};
var down = function(){
//向下跳动
var count2 = 2;
timer2 = setInterval(function(){
count2 --;
myWindow.moveBy(0,50);
myWindow.focus();
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值