XML课后练习答案(二)——JS小测验答案分享

1 . 我们可以在下列哪个 HTML 元素中放置 Javascript 代码?

    . <script>

    . <javascript>

    . <js>

    . <scripting>

答:<script>

 

 

2 . 写 "Hello World" 的正确 Javascript 语法是?

    . ("Hello World")

    . "Hello World"

    . response.write("Hello World")

    . document.write("Hello World")

答:document.write("Hello World")

 

 

 

3 . 插入 Javacript 的正确位置是?

    . <body> 部分

    . <head> 部分

    . <body> 部分和 <head> 部分均可

答:<body> 部分和 <head> 部分均可

 

 

 

4 . 引用名为 "xxx.js" 的外部脚本的正确语法是?

    . <script src="xxx.js">

    . <script href="xxx.js">

    . <script name="xxx.js">

答:

<script src="xxx.js">

 

5 . 外部脚本必须包含 <script> 标签吗?

    . 是

    . 否

答:否

 

 

 

6 . 如何在警告框中写入 "Hello World"?

    . alertBox="Hello World"

    . msgBox("Hello World")

    . alert("Hello World")

    . alertBox("Hello World")

答:alert("Hello World")

 

 

7 . 如何创建函数?

    . function:myFunction()

    . function myFunction()

    . function=myFunction()

答:function myFunction()

 

 

 

8 . 如何调用名为 "myFunction" 的函数?

    . call function myFunction

    . call myFunction()

    . myFunction()

答:myFunction()

 

 

9 . 如何编写当 i 等于 5 时执行一些语句的条件语句?

    . if (i==5)

    . if i=5 then

    . if i=5

    . if i==5 then

答: if (i==5)

 

 

10 . 如何编写当 i 不等于 5 时执行一些语句的条件语句?

    . if =! 5 then

    . if <>5

    . if (i <> 5)

    . if (i != 5)

答:if (i != 5)

 

 

 

11 . 在 JavaScript 中,有多少种不同类型的循环?

    . 三种。for 和for…in以及 while 循环。

    . 四种。for 循环、while 循环、do...while 循环以及 loop...until 循环。

    . 一种。for 循环。

答:三种。for 和for…in以及 while 循环。

 

 

12 . for 循环如何开始?

    . for (i <= 5; i++)

    . for (i = 0; i <= 5; i++)

    . for (i = 0; i <= 5)

    . for i = 1 to 5

答:for (i = 0; i <= 5; i++)

 

 

13 . 如何在 JavaScript 中添加注释?

    .'This is a comment

    . <!--This is a comment-->

    . //This is a comment

答://This is a comment

 

 

 

14 . 可插入多行注释的 JavaScript 语法是?

    . /*This comment has more than one line*/

    . //This comment has more than one line//

    . <!--This comment has more than one line-->

答:/*This comment has more than one line*/

 

 

 

15 . 定义 JavaScript 数组的正确方法是?

    . var txt = new Array="George","John","Thomas"

    . var txt = new Array(1:"George",2:"John",3:"Thomas")

    . var txt = new Array("George","John","Thomas")

    . var txt = new Array:1=("George")2=("John")3=("Thomas")

答:var txt = new Array("George","John","Thomas")

 

 

 

16 . 如何把 7.25 四舍五入为最接近的整数?

    . round(7.25)

    . rnd(7.25)

    . Math.rnd(7.25)

    . Math.round(7.25)

答:Math.round(7.25)

 

 

17 . 如何求得 2 和 4 中最大的数?

    . Math.ceil(2,4)

    . Math.max(2,4)

    . ceil(2,4)

    . top(2,4)

答:Math.max(2,4)

 

 

18 . 打开名为 "window2" 的新窗口的 JavaScript 语法是?

    . open.new("http://www.w3school.com.cn","window2")

    . new.window("http://www.w3school.com.cn","window2")

    . new("http://www.w3school.com.cn","window2")

    . window.open("http://www.w3school.com.cn","window2")

答:window.open("http://www.w3school.com.cn","window2")

 

 

 

19 . 如何在浏览器的状态栏放入一条消息?

    . statusbar = "put your message here"

    . window.status = "put your message here"

    . window.status("put your message here")

    . status("put your message here")

答:window.status = "put your message here"

 

 

20 . 如何获得客户端浏览器的名称?

    . client.navName

    . navigator.appName

    . browser.name

答:navigator.appName

  • 5
    点赞
  • 15
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值