使用javascript创建一个网页 [英] create a web page with javascript on fly
问题描述
是否可以完全使用javascript创建一个网页并打开它
而无需向服务器发送请求?请出示一个简单的样本。提前致谢!
Jack
Hi,
Is that posible to create a web page completely with javascript and open it
without request to server? Please show a simple sample. Thanks in advance!
Jack
推荐答案
" datactrl" <曲*** @ tpg.com.au>在消息中写道
news:41 ******** @ dnews.tpgi.com.au ...
"datactrl" <qu***@tpg.com.au> wrote in message
news:41********@dnews.tpgi.com.au...
>是否可以完全使用javascript创建一个网页并打开
而无需向服务器请求?请出示一个简单的样本。提前致谢!
杰克
Hi,
Is that posible to create a web page completely with javascript and open it without request to server? Please show a simple sample. Thanks in advance!
Jack
网页由网络服务器提供....
当然,您可以创建一个扩展名为.htm(或.html)的文件,然后在Windows资源管理器中双击它,它将打开。没有JavaScript是这样做所必需的
;例如:
< html>
< head>
< title> test1.htm< / title>
< / head>
< body>
< h1> Hello World< / h1>
< / body>
< / html>
您可以使用javascript 创建页面:
< html>
< head>
< title> test2.htm< title>
< script type =" text / javascript">
var htm ="< html>" ;;
htm + ="< head> " ;;
htm + ="< title> test3.htm;
htm + ="< / head>" ;;
htm + ="< body>" ;;
htm + ="< h1> Hello World< / h1>" ;;
htm + ="< / body>" ;;
htm + ="< / html>" ;;
document.write(htm);
< / script>
< / head>
< body>
< h1> Hel lo世界< / h1>
< / body>
< / html>
这会回答你的问题吗?如果没有请澄清。
A Web page is delivered by a Web server....
Of course you can create a file with an .htm (or .html) extension and
double-click on it in Windows Explorer and it will open. No JavaScript is
necessary to do this; for example:
<html>
<head>
<title>test1.htm</title>
</head>
<body>
<h1>Hello World</h1>
</body>
</html>
You can create a page using javascript:
<html>
<head>
<title>test2.htm<title>
<script type="text/javascript">
var htm = "<html>";
htm += "<head>";
htm += "<title>test3.htm;
htm += "</head>";
htm += "<body>";
htm += "<h1>Hello World</h1>";
htm += "</body>";
htm += "</html>";
document.write(htm);
</script>
</head>
<body>
<h1>Hello World</h1>
</body>
</html>
Does this answer your question? If not please clarify.
" McKirahan" <氖** @ McKirahan.com>在消息中写道
news:Con9d.352861
"McKirahan" <Ne**@McKirahan.com> wrote in message
news:Con9d.352861
Fg5.74302@attbi_s53 ...
Fg5.74302@attbi_s53...
" datactrl" <曲*** @ tpg.com.au>在消息中写道
新闻:41 ******** @ dnews.tpgi.com.au ...
"datactrl" <qu***@tpg.com.au> wrote in message
news:41********@dnews.tpgi.com.au...
是否可以用javascript完全创建一个网页并打开
Hi,
Is that posible to create a web page completely with javascript and open
它
没有请求到服务器?请出示一个简单的样本。谢谢
预付款!
Jack
without request to server? Please show a simple sample. Thanks in advance!
Jack
网页由网络服务器提供....
当然你可以创建一个扩展名为.htm(或.html)的文件,然后在Windows资源管理器中双击它,它将打开。这样做不需要JavaScript;例如:
< html>
< head>
< title> test1.htm< / title>
< / head>
< body>
< h1> Hello World< / h1>
< / body>
< / html>
您可以创建一个页面使用javascript :
< html>
< head>
< title> test2.htm< title>
< script type =" text / javascript">
var htm ="< html>" ;;
htm + ="< head>" ;;
htm + = "< title> test3.htm;
htm + ="< / head>" ;;
htm + ="< body>" ;;
htm + = "< h1> Hello World< / h1>" ;;
htm + ="< / body>" ;;
htm + ="< / html>" ;;
document.write(htm);
< / script>
< / head>
< body>
< h1> Hello World< / h1>
< / body>
< / html>
A Web page is delivered by a Web server....
Of course you can create a file with an .htm (or .html) extension and
double-click on it in Windows Explorer and it will open. No JavaScript is
necessary to do this; for example:
<html>
<head>
<title>test1.htm</title>
</head>
<body>
<h1>Hello World</h1>
</body>
</html>
You can create a page using javascript:
<html>
<head>
<title>test2.htm<title>
<script type="text/javascript">
var htm = "<html>";
htm += "<head>";
htm += "<title>test3.htm;
htm += "</head>";
htm += "<body>";
htm += "<h1>Hello World</h1>";
htm += "</body>";
htm += "</html>";
document.write(htm);
</script>
</head>
<body>
<h1>Hello World</h1>
</body>
</html>
Does this answer your question? If not please clarify.
当然
htm + ="< title> test3.htm;
应该是
htm + ="< title> test3.htm< / title>" ;;
这是另一种可能性。
var htm ="< html>" ;;
htm + ="< head>" ;;
htm + ="< title> test4.htm< / title>" ;;
htm + ="< / head>" ;;
htm + = "< body>";
htm + ="< h1> Hello World< / h1>" ;;
htm + ="< / body>" ;;
htm + ="< / html>" ;;
var oIE = new ActiveXObject(" InternetExplorer.Application");
oIE.visible = true;
oIE.navigate(" about :blank");
oIE。 document.open;
oIE.document.write(htm);
oIE.document.close;
Of course
htm += "<title>test3.htm;
should have been
htm += "<title>test3.htm</title>";
Here''s another possibility.
var htm = "<html>";
htm += "<head>";
htm += "<title>test4.htm</title>";
htm += "</head>";
htm += "<body>";
htm += "<h1>Hello World</h1>";
htm += "</body>";
htm += "</html>";
var oIE = new ActiveXObject("InternetExplorer.Application");
oIE.visible = true;
oIE.navigate("about:blank");
oIE.document.open;
oIE.document.write(htm);
oIE.document.close;
这篇关于使用javascript创建一个网页的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!