这是在asp.net的文本里写的
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>无标题页</title>
<script type="text/javascript">
var lin=window.document.createElement("div");
lin.id="linyuan";
window.document.body.appendChild(lin);
document.getElementById("linyuan").innerHTML="1111111111111111111111";
</script>
</head>
<body>
<form id="form1" runat="server">
<div>
</div>
</form>
</body>
</html>
下面是在普通的HTML文本里写的:
<html>
<body>
<script type="text/javascript" language="javascript">
var lin=window.document.createElement("div");
lin.id="linyuan";
window.document.body.appendChild(lin);
document.getElementById("linyuan").innerHTML="1111111111111111111111";
</script>
</body>
</html>活见鬼了,在asp.net中 JAVASCRIPT代码的效果显示不出来?
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>无标题页</title>
<script type="text/javascript">
var lin=window.document.createElement("div");
lin.id="linyuan";
window.document.body.appendChild(lin);
document.getElementById("linyuan").innerHTML="1111111111111111111111";
</script>
</head>
<body>
<form id="form1" runat="server">
<div>
</div>
</form>
</body>
</html>
下面是在普通的HTML文本里写的:
<html>
<body>
<script type="text/javascript" language="javascript">
var lin=window.document.createElement("div");
lin.id="linyuan";
window.document.body.appendChild(lin);
document.getElementById("linyuan").innerHTML="1111111111111111111111";
</script>
</body>
</html>活见鬼了,在asp.net中 JAVASCRIPT代码的效果显示不出来?
解决方案 »
- ASP.NET动态显示时间的问题(有难度哦)
- lxcnn在么?求一个正则表达式
- 新手请教!
- 如何在更新数据库时,同时更新缓存的数据(不丢弃缓存再重新读取数据来缓存)
- 未能加载类型
- 为什么无法获取ListBox的Text值?
- 给Session["xx"]直接 赋值 是保存在session哪?
- 用<META HTTP-EQUIV="Refresh" CONTENT="5;URL=<%=source%>" >实现自动跳转,老是失败
- CMS是什么干嘛的?
- 各位:我装了 visual studio.net 为什么当新建项目时总是出现“没有权限”错误信息,然后就没办法新建了吗?
- 内网,有许多子网站,采用不同技术(IIS 或 APach)请问怎样做一个 计数器 站点,详细记录每个网站的访问量??(一个站点的我会做)
- 关于FCK编辑器的问题
<title>无标题页 </title>
<script type="text/javascript">
var lin=window.document.createElement("div");
lin.id="linyuan";
window.document.body.appendChild(lin);
document.getElementById("linyuan").innerHTML="1111111111111111111111";
</script>
</head> 要把head的runat="server"去掉才行的, 否则里面的<都会被转义成<自己查看一下asp.net输出页面的源文件就知道了.
1.document.createElement是在页面加载以后才能使用。
因为在asp.net里面要处理后台代码。
2.在html不会出现这样的问题是因为不存在回调。
3.你可以把在页面加载后用个事件调用你写的那个函数,就不会出现这样的问题了。
4.你可以用document.write(<div></div>)
5.这个div的display:none;
6.这样你可以在其它方法方便的调用了。
只有把文件里的<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 还有head里的server删掉才能用。具体解决办法还不知道。谁能帮个忙。