<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>无标题页</title>
<script >
window.onload=function()
{
document.getElementById("Label1").innerHTML="11";
}
function ss()
{
document.getElementById("Label2").innerHTML="22";
}
</script>
</head>
<body onload="ss()">
<form id="form1" runat="server">
<div>
<asp:Label ID="Label1" runat="server" Text="Label"></asp:Label>
<asp:Label ID="Label2" runat="server" Text="Label"></asp:Label>
</div>
</form>
</body>
</html>
上面只执行ss(),因为执行先后顺序.要求:在页面加载时同时执行2个函数.
注意:1.必须在body中写一个调用(且只能写一个)
2.另外一个必须不能在body中写.而且还必须是单独的函数.以下可以解决.但不符合要求,请高手想想别的办法.
1.<body onload="ss();others()">
2.window.onload=function()
{
ss();
document.getElementById("Label1").innerHTML="11";
}
<head runat="server">
<title>无标题页</title>
<script >
window.onload=function()
{
document.getElementById("Label1").innerHTML="11";
}
function ss()
{
document.getElementById("Label2").innerHTML="22";
}
</script>
</head>
<body onload="ss()">
<form id="form1" runat="server">
<div>
<asp:Label ID="Label1" runat="server" Text="Label"></asp:Label>
<asp:Label ID="Label2" runat="server" Text="Label"></asp:Label>
</div>
</form>
</body>
</html>
上面只执行ss(),因为执行先后顺序.要求:在页面加载时同时执行2个函数.
注意:1.必须在body中写一个调用(且只能写一个)
2.另外一个必须不能在body中写.而且还必须是单独的函数.以下可以解决.但不符合要求,请高手想想别的办法.
1.<body onload="ss();others()">
2.window.onload=function()
{
ss();
document.getElementById("Label1").innerHTML="11";
}
function A()
{
document.getElementById("Label1").innerHTML="11";
B();
}
function B()
{
document.getElementById("Label2").innerHTML="22";
}
在一个函数中使用就是
<script >
others();
</scrip>
<body onload="ss()"> function ss()
{
document.getElementById("Label2").innerHTML="22";
others(); }
要求:在页面加载时同时执行2个函数.
注意:1.必须在body中写一个调用(且只能写一个)
2.另外一个必须不能在body中写.而且还必须是单独的函数. 以下可以解决.但不符合要求,请高手想想别的办法.
1. <body onload="ss();others()">
2.window.onload=function()
{
ss();
document.getElementById("Label1").innerHTML="11";
}