| |

VerySource

 Forgot password?
 Register
Search
View: 770|Reply: 6

How to determine the first time a page is entered with javascript

[Copy link]

1

Threads

2

Posts

3.00

Credits

Newbie

Rank: 1

Credits
3.00

 China

Post time: 2020-2-11 18:30:02
| Show all posts |Read mode
How to determine the first time a page is entered using javascript,
IsPostBack-like effect
Reply

Use magic Report

0

Threads

15

Posts

12.00

Credits

Newbie

Rank: 1

Credits
12.00

 Japan

Post time: 2020-4-30 12:45:01
| Show all posts
Simple is to read cookies
Reply

Use magic Report

0

Threads

29

Posts

23.00

Credits

Newbie

Rank: 1

Credits
23.00

 China

Post time: 2020-4-30 13:45:01
| Show all posts
Set a public variable, add one every time it loads, and check the value
Reply

Use magic Report

0

Threads

2

Posts

2.00

Credits

Newbie

Rank: 1

Credits
2.00

 China

Post time: 2020-4-30 19:15:01
| Show all posts
<html>
<input type = "hidden" id = "flag" value = "0" />
<script language = javascript>
function test ()
{
  var flag = document.getElementById ("flag");
  if (flag.value == "0")
  {
    // first time
    alert ("first time");
    flag.value = "1";
  }
  else
  {
    alert ("not first time");

  }
}
</ script>
<body onload = "test ();">
</ html>
Reply

Use magic Report

0

Threads

15

Posts

12.00

Credits

Newbie

Rank: 1

Credits
12.00

 Japan

Post time: 2020-4-30 19:30:01
| Show all posts
Also determine whether document.referrer is yourself
Reply

Use magic Report

1

Threads

2

Posts

3.00

Credits

Newbie

Rank: 1

Credits
3.00

 China

 Author| Post time: 2020-4-30 21:15:01
| Show all posts
toweh007
How to set a public variable? Thank you
Reply

Use magic Report

0

Threads

2

Posts

2.00

Credits

Newbie

Rank: 1

Credits
2.00

 China

Post time: 2020-4-30 22:00:02
| Show all posts
If there is a jump, use document.cookies
Reply

Use magic Report

You have to log in before you can reply Login | Register

Points Rules

Contact us|Archive|Mobile|CopyRight © 2008-2023|verysource.com ( 京ICP备17048824号-1 )

Quick Reply To Top Return to the list