| |

VerySource

 Forgot password?
 Register
Search
View: 673|Reply: 3

Response.Write&ClientScript.RegisterStartupScript

[Copy link]

1

Threads

1

Posts

2.00

Credits

Newbie

Rank: 1

Credits
2.00

 China

Post time: 2020-2-8 16:30:01
| Show all posts |Read mode
Brothers, is there any difference between the two methods of executing scripts? Are there any restrictions on the script code? Which is better? Under what circumstances is it appropriate to use one?
Reply

Use magic Report

0

Threads

64

Posts

45.00

Credits

Newbie

Rank: 1

Credits
45.00

 China

Post time: 2020-4-1 12:00:02
| Show all posts
ClientScript.RegisterStartupScript
Feel this better
Reply

Use magic Report

0

Threads

15

Posts

10.00

Credits

Newbie

Rank: 1

Credits
10.00

 China

Post time: 2020-4-1 12:45:01
| Show all posts
Response.Write writes directly in the stream
Meaning, if you write in background code
Output to the front of the document <html>
RegisterStartupScript will write the code into <head>
Reply

Use magic Report

0

Threads

29

Posts

19.00

Credits

Newbie

Rank: 1

Credits
19.00

 China

Post time: 2020-4-1 22:00:02
| Show all posts
ClientScript.RegisterStartupScript
This is usually added at the beginning of the form
<form id = "form1" ...> <!-added here at the beginning->
<script>
some code
</ script>
</ form>

Response.Write is generally where you add the script where you write

ClientScript.RegisterStartupScript There is also a RegisterBlock xxx I can't remember, it is to add the script before the end of the form tag

The location of the script generally has no effect, but sometimes the Internet speed is slow. When the entire web page is not loaded and played, the <script> in the body tag is loaded first, and then it will be executed first. But some objects haven't been loaded recently, an error will occur, saying that the object does not exist.
<Script defer = "defer" type = "text / javascript" language = "javascript"> </ script>
Adding defer can delay the script running, and then run the script after the web page is loaded.
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