怎样在网页中插入JavaScript代码

怎样在网页中插入JavaScript代码,第1张

步骤

1、新建一网页文件“sample.html",用记事本或其它文本编辑软件(如UltraEdit)打开,输入如图所示的HTML代码。该网页文件包括一个蓝色的字符串,一个按钮和一个文本框。

2、JS代码可插入到”head"标签之间。编写Javascript代码,代码内容如图所示,并将该段代码复制到网页文件”sample.html“中标签”<head>"和“</head>之间,然后查看网页文件的显示内容。

var str1,str2,str3,str4

str1 = new String("tom")

str2 = new String("tom")

str3 = "tom"

document.write(str1==str2)

document.write(",")

document.write(str1===str2)

document.write(",")

document.write(str1==str3)

document.write(",")

document.write(str1===str3)

document.write(",")

str4 = str1.concat(" jerry")

document.write(str4)

望采纳!


欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/bake/11396828.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023-05-15
下一篇 2023-05-15

发表评论

登录后才能评论

评论列表(0条)

保存