Skip to content
Toggle navigation
Toggle navigation
This project
Loading...
Sign in
任超
/
js.portalStaticPage
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Network
Create a new issue
Builds
Commits
Issue Boards
Files
Commits
Network
Compare
Branches
Tags
7956505d
authored
2020-12-24 10:55:10 +0800
by
任超
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
style:监听浏览器关闭
1 parent
b57d0c0a
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
21 additions
and
9 deletions
staticJs/login.js
staticJs/login.js
View file @
7956505
...
...
@@ -20,9 +20,6 @@ function login() {
});
})
}
window
.
onbeforeunload
=
function
()
{
delCookie
();
}
$
(
document
).
on
(
'click'
,
'.PersonLogin'
,
function
()
{
login
();
})
...
...
@@ -42,16 +39,16 @@ $(document).on('click', '#loginButton', function () {
$
(
document
).
on
(
'click'
,
'#cancellation'
,
function
()
{
layui
.
use
(
'layer'
,
function
()
{
layer
.
confirm
(
'此操作将进行注销'
,
{
btn
:
[
'是'
,
'否'
]
//按钮
},
function
()
{
btn
:
[
'是'
,
'否'
]
//按钮
},
function
()
{
delCookie
();
window
.
open
(
''
+
localhostPaht
+
'/index.html'
,
'_self'
)
},
function
()
{
},
function
()
{
layer
.
msg
(
'已取消'
);
});
})
});
function
delCookie
()
{
function
delCookie
()
{
var
keys
=
document
.
cookie
.
match
(
/
[^
=;
]
+
(?=
=
)
/g
)
if
(
keys
)
{
for
(
var
i
=
keys
.
length
;
i
--
;)
{
...
...
@@ -68,10 +65,25 @@ $(function () {
if
(
getCookie
(
'myCookie'
).
username
)
{
$
(
'.personalCenter'
).
addClass
(
'show'
);
}
var
_beforeUnload_time
=
0
,
_gap_time
=
0
;
var
is_fireFox
=
navigator
.
userAgent
.
indexOf
(
"Firefox"
)
>
-
1
;
//是否是火狐浏览器
window
.
onunload
=
function
()
{
_gap_time
=
new
Date
().
getTime
()
-
_beforeUnload_time
;
if
(
_gap_time
<=
5
)
{
delCookie
();
}
else
{
//浏览器刷新
}
}
window
.
onbeforeunload
=
function
()
{
_beforeUnload_time
=
new
Date
().
getTime
();
if
(
is_fireFox
)
{
//火狐关闭执行
delCookie
();
}
};
})
// 点击注册的时候
$
(
document
).
on
(
'click'
,
'#registerButton'
,
function
()
{
window
.
open
(
''
+
localhostPaht
+
'/staticViews/register.html'
,
'_self'
)
window
.
open
(
''
+
localhostPaht
+
'/staticViews/register.html'
,
'_self'
)
});
function
clicklogin
(
data
)
{
$
.
ajax
({
...
...
@@ -84,7 +96,7 @@ function clicklogin(data) {
data
:
JSON
.
stringify
(
data
),
//***关键******
success
:
function
(
result
)
{
//返回数据根据结果进行相应的处理
if
(
result
.
code
==
200
&&
result
.
data
!==
null
)
{
setCookie
(
'myCookie'
,
result
.
data
,
60
);
setCookie
(
'myCookie'
,
result
.
data
,
60
);
$
(
'.personalCenter'
).
addClass
(
'show'
);
$
(
'.PersonLogin'
).
html
(
getCookie
(
'myCookie'
).
username
);
layer
.
closeAll
();
...
...
Please
register
or
sign in
to post a comment