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>

How to run a function when the page is loaded?的更多相关文章

  1. 【转载】selenium with PhantomJs wait till page fully loaded?

    I use Selenium with Phantomjs, and want to get the page content after the page fully loaded. I tried ...

  2. Page与Loaded

    When navigate to page, loaded event will be triggered. Back to page, loaded event will be triggered ...

  3. 开发并调试 Mail Add-in

    开发并调试 Mail Add-in (mail app for Outlook) 准备工作 如果你的邮箱搭建在 Exchange Server 上,则可以创建邮件应用程序(Mail Add-in)来扩 ...

  4. 建立你第一个 Outlook Add-in

    最近因为工作需要,研究了下Outlook Add-in 和 Graph API.下面带大家建立一个Hello World 项目 建立Add-in 先前需求: Node.js 使用cmd/PowerSh ...

  5. 使用 Visual Studio 开发并调试 Mail Add-in (mail app for Outlook)

    准备工作 如果你的邮箱搭建在 Exchange Server 上,则可以创建邮件应用程序(Mail Add-in)来扩展Office本身的功能,使用 Office Add-in Model 开发的 M ...

  6. UI——DOM

    原文链接:Introduction to the DOM Introduction The Document Object Model, usually referred to as the DOM, ...

  7. JavaScript的知识基本介绍

    ECMAScript js简单介绍(与java的区别)        1.语法(区分大小写,弱类型,分号可写可不写)        2.变量(只能使用var定义,要么不定义,如果在函数内部使用var定 ...

  8. JavaScript学习笔记(八)—— 补

    第九章 最后的补充 一.Jquery简单阐述 JQuery是一个JavaScript库,旨在减少和简化处理DOM和添加视觉效果的JavaScript代码:使用时必须得添加库路径:学习路径:http:/ ...

  9. How to call javascript function on page load in asp.net

    How to call javascript function on page load in asp.net 解答1,使用RegisterStartupScript来运行 需要注意的是,下面的dem ...

随机推荐

  1. JDK11 | 第六篇 : Epsilon 垃圾收集器

    文章首发于公众号<程序员果果> 地址 : https://mp.weixin.qq.com/s/RhGXJImhp7Xm-wDrpPomkQ 一.简介 Epsilon(A No-Op Ga ...

  2. Vue.nextTick浅析

    Vue.nextTick浅析 Vue的特点之一就是响应式,但数据更新时,DOM并不会立即更新.当我们有一个业务场景,需要在DOM更新之后再执行一段代码时,可以借助nextTick实现.以下是来自官方文 ...

  3. antd组件Upload实现自己上传

    前言 在实现图片上传时,可能需要用到Upload,但是它默认的上传方式是加入图片后直接上传,如果要实现最后再一次性上传,需要自定义内容. //添加按钮的样式 const uploadButton = ...

  4. UvaLive 6664 Clock Hands

    链接:http://vjudge.net/problem/viewProblem.action?id=49409 题意:给一个奇怪的能够记录N小时内时间的表(生活中的表是12小时计时的). 而且给出一 ...

  5. xilinx基础入门

    2019.09.03 一.基础部分及语法 一.FPGA程序的固化 [USF-XSim-62] 'simulate' step failed with errors. Please check the ...

  6. 计算机系统结构总结_Memory Hierarchy and Memory Performance

    Textbook: <计算机组成与设计——硬件/软件接口>  HI <计算机体系结构——量化研究方法>       QR 这是youtube上一个非常好的memory syst ...

  7. go & cron

    https://github.com/robfig/cron - 源码 cron - GoDoc 参考 go---定时任务 cron,gin 静态文件 go语言里比较好用的计划任务调度模块

  8. Spark Streaming整合Flume + Kafka wordCount

    flume配置文件 flume_to_kafka.conf a1.sources = r1 a1.sinks = k1 a1.channels = c1 a1.sources.r1.type = sp ...

  9. iOS 设备尺寸以及图标尺寸

    iPhone 4和iPod Touch 4有一个新的特性:在屏幕尺寸不变的前提下,分辨率提升一倍(320 x 480 => 640 x 960).苹果将这个特性命名为Retina. 用苹果的话讲 ...

  10. centos虚拟机配置网卡连接

    本地连接 centos虚拟机连接设置: 换过ip之后需要重启网络服务新ip才生效 #service network restart 修改dns: