JS对话框

来源:互联网 发布:vk社交软件下载 编辑:程序博客网 时间:2024/06/05 09:50
<html><head><script type="text/javascript">function message(){alert("该提示框是通过 onload 事件调用的。")}</script></head><body onload="message()"></body></html>

js小实例

弹出一个对话消息框


<html><head></head><body><script type="text/javascript">document.write("该消息在页面加载时输出。")</script></body></html>

用document  对象的write方法写出一行文本


<!DOCTYPE html><html><head><script>function myFunction(){document.getElementById("demo").innerHTML="My First JavaScript Function";}</script></head><body><h1>My Web Page</h1><p id="demo">A Paragraph</p><button type="button" onclick="myFunction()">Try it</button></body></html>

在head里面定义一个js函数

首先通过

document.getElementById
这个方法获得短路的id然后利用JS函数修改

原创粉丝点击