How to run a function when the page is loaded?
to The is How Function when run Page
2023-09-11 14:14:20 时间
How to run a function when the page is loaded?
window.onload = codeAddress;
should work - here's a demo, and the full code:
方法1
<!DOCTYPE html> <html> <head> <title>Test</title> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <script type="text/javascript"> function codeAddress() { alert('ok'); } window.onload = codeAddress; </script> </head> <body> </body> </html>
方法2
<!DOCTYPE html> <html> <head> <title>Test</title> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <script type="text/javascript"> function codeAddress() { alert('ok'); } </script> </head> <body onload="codeAddress();"> </body> </html>
相关文章
- yum提示Another app is currently holding the yum lock; waiting for it to exit...
- yii2定时任务不执行,报错PHP date调用警告:It is not safe to rely on the system's timezone settings
- [Angular] Getting to Know the @Attribute Decorator in Angular
- [Javascript] lodash: memoize() to improve the profermence
- How to resolve ASSERTION_FAILED error when you register the odata service expose
- the code place where the binding is converted to final value displayed in u
- Unable to lock the administration directory (/var/lib/dpkg/),is another process using it?
- 报错: Access restriction: The type JPEGImageEncoder is not accessible due to restriction on required library
- 已解决The conversion of the nvarchar value ‘10033121171441‘ overflowed an int column
- [手游项目2]-2-【libprotobuf ERROR 】Use the 'bytes' type if you intend to send raw bytes.
- 全网多种方法解决You have an error in your SQL syntax; check the manual that corresponds to your MySQL server
- Solved Unable to copy the source file ./installer/services.sh to the destination file /etc/vmware-t
- [Android]The connection to adb is down, and a severe error has occured.
- DescriptionResourcePathLocationType Project configuration is not up-to-date with pom.xml. Select: Maven->Update Project... from the project context menu or use Quick Fix.spark-MTline 1Maven Co
- 魔戒 (The Lord of the Rings,又译《指环王》)
- 问题解决:The connection to the server xxxxx:6443 was refused - did you specify the right host or port?
- org.apache.subversion.javahl.ClientException: svn: E155021: This client is too old to work with the
- DB2 “The transaction log for the database is full” 存在的问题及解决方案
- Warning: (3719, “‘utf8’ is currently an alias for the character set UTF8MB3, which will be replaced by UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous.”)
- strip: Unable to recognise the format of the input file
- MySQL----JDBC无法连接数据库,报The driver has not received any packets from the server的解决办法
- ERROR 1290 (HY000): The MySQL server is running with the --secure-file-priv option so it cannot ···
- 存在隐患 : 3 racks are required for the erasure coding policies: RS-6-3-1024k. The number of racks is on
- (六)Jenkins部署项目报错The username you provided is not allowed to use the text-based Tomcat Manager (error
- AS编译的报错提示:Failed to query the value of property ‘namespace‘
- K8S 证书过期,报错:Unable to connect to the server: x509: certificate has expired or is not yet valid 解决方法