to yixianggao(你我他,三人行必有我师焉!) 我是在服务器端用ScriptManager.RegisterStartUpScript注册的. 可是不用alert就不行, 怎么样在服务器端把js注册到你说的位置阿
ClientScriptManager.RegisterStartupScript Method (Type, String, String) The script block added by the RegisterStartupScript method executes when the page finishes loading but before the page's OnLoad event is raised.看来不是位置的问题,是不是用了 iframe 或 frame 什么的?LZ 到底想实现什么效果,并且把脚本代码和 html 页面代码贴出来看看!大家帮你分析分析!
to yixianggao(你我他,三人行必有我师焉!) 以下是代码,代码的功能是用一个div将另外一个div盖住,但是当被盖住的div有滚动条时,不能把滚动条也盖住。这里的代码包含两种实现方式: 第一种是通过Ajax的ScriptManager.RegisterStartUpScript来调用,这种调用能够使div可见,但是把滚动条也盖住了,说明代码执行时滚动条还没有出现。 第二种是用ajax的EndRequest来调用,也是一样,能够使div可见,但是把滚动条也盖住了,说明代码执行时滚动条还没有出现。在第二种方法中,如果在调整div大小前调用一下alert,执行的时候点击完alert确定按钮之后,滚动条就不被盖住了,说明执行有效了。现在不想出现alert,该如何才能实现这个功能哪? 谢谢 ------------------------- <div id="divForContent" style="filter:alpha(opacity=0);width:503px;font:20;z-index:1000;background-color:#FF0000;position:absolute; left: 11px; top: 85px; height: 87px;"></div> <script type="text/javascript"> //这里是ajax的EndRequest事件 function EndRequest (sender, args) { if( postBackElement.id == document.getElementById("<%= tvItems.ClientID %>").id ) { //fill the item content back into the divContent from server-side control. document.getElementById("divItemContent").innerHTML = document.getElementById("<%= txtContent.ClientID %>").value;
yixianggao(你我他,三人行必有我师焉!) 我是在服务器端用ScriptManager.RegisterStartUpScript注册的.
可是不用alert就不行,
怎么样在服务器端把js注册到你说的位置阿
第一种是通过Ajax的ScriptManager.RegisterStartUpScript来调用,这种调用能够使div可见,但是把滚动条也盖住了,说明代码执行时滚动条还没有出现。
第二种是用ajax的EndRequest来调用,也是一样,能够使div可见,但是把滚动条也盖住了,说明代码执行时滚动条还没有出现。在第二种方法中,如果在调整div大小前调用一下alert,执行的时候点击完alert确定按钮之后,滚动条就不被盖住了,说明执行有效了。现在不想出现alert,该如何才能实现这个功能哪?
谢谢
------------------------- <div id="divForContent" style="filter:alpha(opacity=0);width:503px;font:20;z-index:1000;background-color:#FF0000;position:absolute; left: 11px; top: 85px; height: 87px;"></div>
<script type="text/javascript">
//这里是ajax的EndRequest事件
function EndRequest (sender, args)
{
if( postBackElement.id == document.getElementById("<%= tvItems.ClientID %>").id )
{
//fill the item content back into the divContent from server-side control.
document.getElementById("divItemContent").innerHTML = document.getElementById("<%= txtContent.ClientID %>").value;
divForItemContent.style.display = "block";//这句执行成功了
// alert(divItemContent.clientWidth); divForItemContent.style.width = divItemContent.clientWidth;
divForItemContent.style.height = divItemContent.clientHeight; }
}//自己写的函数
function ShowDivForContent()
{
divForItemContent.style.display = "block";
divItemContent.style.borderColor = "#000000";
divForItemContent.style.width = divItemContent.clientWidth;
divForItemContent.style.height = divItemContent.clientHeight;
}
</script><script runat="server">
ScriptManager.RegisterStartupScript(UpdatePanel4, this.GetType(), DateTime.Now.ToString(), "ShowDivForContent();", true);
</script>
divForContent应该是divForItemContent
共有两个div: divItemContent 和 divForItemContent .
所以这句应该是:
<div id="divForItemContent" style="filter:alpha(opacity=0);width:503px;font:20;z-index:1000;background-color:#FF0000;position:absolute; left: 11px; top: 85px; height: 87px;"></div>
---------------------------------------------------------------------------
这句话:
document.getElementById("divItemContent").innerHTML = document.getElementById("<%= txtContent.ClientID %>").value;是把服务器端的TextBox的内容复制到客户端的div中.
要复制的内容很多,具体的内容是Html格式的内容,可能包含文本,图片,链接等.
最长可能达到几万字.Html的代码太长,而且与其他页面关联.不知道上述信息是否足够,谢谢
因为找不到事件!大家都来说说!
代码如下,LZ 更具自己的情况改改吧: <body>
<div id="divForItemContent" style="filter:alpha(opacity=50);width:500px; height: 100px; font:20;z-index:1000;background-color:#FF0000; position:absolute; left: 11px; top: 85px;"></div> <div id="divItemContent" style="overflow: auto; width:500px; height: 100px; font:20;z-index:999;background-color:#0000ff;position:absolute; left: 11px; top: 85px;">
</div> <script type="text/javascript">
<!--
divItemContent.innerHTML = "<br /> <br /> <br /> <br /> <br /> <br /> <br /> <br /> <br /> <br /> <br /> <br /> <br /> <br /> <br /> <br /> <br /> <br /> <br /> <br />";
// 延时时段,单位 毫秒,1秒=1000毫秒。
var delayInterval = 100;
window.setTimeout(resizeDiv, delayInterval);
function resizeDiv()
{
divForItemContent.style.width = divItemContent.clientWidth;
divForItemContent.style.height = divItemContent.clientHeight;
}
//-->
</script>
</body>
yixianggao(你我他,三人行必有我师焉!) ( ) 信誉:100 Blog 加为好友