JavaScript两个常用的客户端输出方法

常用的两个客户端输出方法


document.write(str)

  • 描述:在网页的<body>标记,输出str的内容。

  • document意思“文档”,就是整个网页了。

  • document是一个文档对象,代表整个网页。

  •  write()是document对象的一个输出方法。

  • “.”小数点:通过小数点(.)来调用对象的方法。

  • str:表示要输出的内容。

<!DOCTYPE HTML>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
        <title>php.cn</title>
        <script type="text/javascript">
            //在<body>中输出一句话
            document.write("欢迎来到php.cn");
        </script>
    </head>
    <body>
    </body>
</html>


window.alert(str)

  • 描述:在当前窗口中弹出一个警告对话框,str为对话框中显示的内容。

  • window代表当前浏览器窗口,window是一个窗口对象。

  • alert()方法:弹出一个对话框。

  • str:表示要输出的内容。

<!DOCTYPE HTML>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
        <title>php.cn</title>
        <script type="text/javascript">
            //打开网页时,弹出一个对话框
            window.alert("欢迎来到php.cn");
        </script>
    </head>
    <body>
    </body>
</html>


继续学习
||
<!DOCTYPE HTML> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <title>php.cn</title> <script type="text/javascript"> //在<body>中输出一句话 document.write("欢迎来到php.cn"); </script> </head> <body> </body> </html>
提交重置代码
章节
笔记
提问
课件
反馈
捐赠

javascript初级教程

  • 推荐课程
  • 评论
  • 问答
  • 笔记
  • 课件下载
Air张

Air张

问题解答: 1.继续学习点击右侧章节往下; 2.加不加分号都可以,分号就是结束当前语句; 3.document.write()和document.getElementById()不是一个概念;

4年前    添加回复 0

回复
(_致囿メ嫒鉨

(_致囿メ嫒鉨

点继续学习怎么跳转到其它视频教学去了

4年前    添加回复 0

回复
Martin_Wu

Martin_Wu

为什么document.Write();这个语句后面要加分号?而window.alert()不用?

4年前    添加回复 0

回复
一辆想出轨的无轨电车

一辆想出轨的无轨电车

document.write这个我觉得没有document.getElementById用的多

5年前    添加回复 0

回复
Alway.以为

Alway.以为

经常能看到这种效果,学学怎么写的

5年前    添加回复 0

回复
我喜欢晴天

我喜欢晴天

两个输出方式都很常用啊

5年前    添加回复 0

回复
末日的春天

末日的春天

window.alert初学时候用的多

5年前    添加回复 0

回复
橱窗的光

橱窗的光

自己在下面试了一下document.write() 括号里面是写输出的内容

5年前    添加回复 0

回复
范凡

范凡

document意思“文档”,就是整个网页了。 document是一个文档对象,代表整个网页。 write()是document对象的一个输出方法。 “.”小数点:通过小数点(.)来调用对象的方法。 str:表示要输出的内容。

3年前 0

V.

V.

JavaScript两个常用的客户端输出方法 doucument.write() //doucument网页 window.alert() //window窗口 弹出一个对话框

4年前 0

dabour

dabour

<script type="text/javascript"> //在<body>中输出一句话 document.write("欢迎来到php.cn"); window.alert("I am yufeng xiao"); </script> 先显示alert的内容,再显示write的内容

4年前 0

Mr.L

Mr.L

JavaScript常用两个客户端输出方法 document.write window.alert

5年前 0

素颜

素颜

描述:在网页的<body>标记,输出str的内容。 document意思“文档”,就是整个网页了。 document是一个文档对象,代表整个网页。 write()是document对象的一个输出方法。 “.”小数点:通过小数点(.)来调用对象的方法。 str:表示要输出的内容。

5年前 0

我喜欢晴天

我喜欢晴天

常用的两个客户端输出方法 document.write(str) window.alert(str)

5年前 0

课件暂不提供下载,工作人员正在整理中,后期请多关注该课程~