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. Java——LinkedList底层源码分析

    1.简介 LinkedList 是用链表结构存储数据的,很适合数据的动态插入和删除,随机访问和遍历速度比较慢.另外,他还提供了 List 接口中没有定义的方法,专门用于操作表头和表尾元素,可以当作堆栈 ...

  2. 关于XML的一些事

    XML:可扩展标记语言! 01.很像HTML 02.着重点是数据的保存 03.无需预编译 04.符合W3C标准 可扩展:我们可以自定义,完全按照自己的规划来! 标记:计算机所能认识的信息符号! 比如: ...

  3. Eureka 源码分析之 Eureka Client

    文章首发于微信公众号<程序员果果> 地址:https://mp.weixin.qq.com/s/47TUd96NMz67_PCDyvyInQ 简介 Eureka是一种基于REST(Repr ...

  4. Luogu P5339 [TJOI2019]唱、跳、rap和篮球

    题目 设\(f_i\)表示从\((a-4i,b-4i,c-4i,d-4i)\)中选\(n-4i\)个排队的方案数. 那么我们可以容斥,答案为\(\sum\limits_{i=0}^{lim}(-1)^ ...

  5. checkbox的全选、全消的使用

    jquery的选择器的使用 //全选,全消 $("#check_all").click(function () { state = $(this).prop("check ...

  6. Python webdriver调用Chrome报错

    报错信息如下: selenium.common.exceptions.WebDriverException: Message: 'chromedriver' executable needs to b ...

  7. 禁止input输入框历史记录

    <input type="text" autocomplete="off" />

  8. Site error: the ionCube PHP Loader needs to be installed.解决办法

    问题描述: 有些模块的作者为了保护代码而采用ionCube加密的代码,所以这里必须给服务器装上这个php的扩展,就好像以前的zend一样 解决办法: http://bbs.52jscn.com/thr ...

  9. MySql二进制版安装教程

    1.检查是否已安装过mariadb,若有便删除(linux系统自带的) [root@localhost /]# rpm -qa | grep mariadb [root@localhost /]# r ...

  10. 面试编程题拾遗(06) --- 打印n对括号的全部有效组合

    如题所述,当n=3时,可能的组合有:(()()), ((())), ()(()), (())(), ()()() 代码如下(有注释): import java.util.ArrayList; impo ...