编辑文本后点击显示结果
返回网页教程首页
<html> <head><title>Javascript变量申明赋值显示的示例代码</title></head> <body> <script type="text/javascript"> var domainname= "aspxhome.com/chm/html"; document.write(domainname); document.write("<h1>"+domainname+"</h1>"); </script> <p>这段Javascript代码中,第一行申明了一个变量domainname,并同时将一个字符串"aspxhome.com/chm/html"赋值给这个变量;第二行用document.write显示变量domainname的值;第三行显示带h1标题格式的变量domainname的值。</p> </body> </html>