js如何让弹窗碰到边缘反弹 20
如何通过js制作一个页面,点击button后弹出一个网页为弹窗,然后弹窗在屏幕中移动,碰到边缘后反弹,要弹出的是另一个页面而不是图片,求大神赐教!...
如何通过js制作一个页面,点击button后弹出一个网页为弹窗,然后弹窗在屏幕中移动,碰到边缘后反弹,要弹出的是另一个页面而不是图片,求大神赐教!
展开
展开全部
<!DOCTYPE HTML>
<html>
<head>
<meta charset=utf-8 />
<title>UFO来了</title>
<script src="jQuery/js/jquery-1.11.3.min.js"></script>
<script>
$(function() {
var i = j = 10;
var e = $("#target");
var win = $(window);
function intern() {
var width = e.width();
var height = e.height();
var left = parseInt(e.css("left"));
var top = parseInt(e.css("top"));
var windowWidth = win.width();
var windowHeight = win.height();
if (windowWidth - width < (left + i)) {
i = -i;
} else if ((left + i) < 0) {
i = -i;
}
if (windowHeight - height < (top + j)) {
j = -j;
<html>
<head>
<meta charset=utf-8 />
<title>UFO来了</title>
<script src="jQuery/js/jquery-1.11.3.min.js"></script>
<script>
$(function() {
var i = j = 10;
var e = $("#target");
var win = $(window);
function intern() {
var width = e.width();
var height = e.height();
var left = parseInt(e.css("left"));
var top = parseInt(e.css("top"));
var windowWidth = win.width();
var windowHeight = win.height();
if (windowWidth - width < (left + i)) {
i = -i;
} else if ((left + i) < 0) {
i = -i;
}
if (windowHeight - height < (top + j)) {
j = -j;
本回答被网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询