IE好像能用function window.onload(),但是,换成chome就不行了,怎么回事啊,出了这个,还有其他的方法吗?
解决方案 »
- 请教一个js版本google地图的缩放级别的问题
- ext chart图刷新问题
- 关于ASP循环语句中DIV层ID重名,如何解决!
- 求一个带搜索功能的目录树
- pixelHeight与offsetHeight的问题
- 求大神jquery获取<ul><li><a></a></li></ul>值问题
- javascript是没有办法完全彻底保密的吗?
- 各位兄长救命啊, 怎么用javascript获得本机的当前语言阿。
- 后台表单提交后,刷新前台数据,这个问题怎么解决!
- jquery mobile引起表单重复提交
- 使用FreeTextBox时候JS错误、在线等100分献上
- 给table做全选功能时发现IE会假死怎么办?
window.onload=function() {
alert("加载完毕了");
}
这样写后也没有弹出"string"啊!
<title></title>
<script type="text/javascript">
window.onload = function() { alert('what?'); }
</script>
</head>得写在<script />区块内。或者把
<script type="text/javascript">
alert('what?');
</script>
放在</body>结束前也行。如果是asp.net,后台代码里写:
Page.ClientScript.RegisterStartupScript(this.GetType(), "key", "alert('what?');", true);
window.onload = function() {
alert("page loaded!");
};
</script>
我不相信你这次弹不出来!
---
但是,如果要在加载完后执行多个函数的话,就需要如下:
window.attachEvent('onload',fun1);
window.attachEvent('onload',fun2);
以上是IE版本,FF等版本为使用addEventListener函数
---
如果是JQuery的话,可以用
$(document).ready(function(){});
也可以用JQuery的bind来做
<head runat="server">
<script type="text/javascript" language="javascript">
function GetResouceContent()
{
var message = 'ActiveType=GetResourceContent';
var context='Page1';
<%=getResourceContentCallBack %>
}
function ShowFieldInfo()
{
var o = document.getElementById("LayerList");
var message = 'ActiveType=ShowFieldInfo&EventArg=';
message += o.value;
var context = 'Page1';
<%=ShowFieldInfoCallBack %>
}
</script>
<title>NorthAmericaMap</title>
<link href="css/style1.css" type="text/css" rel="Stylesheet" />
<style type="text/css">
.style4
{ width: 118px;
}
.style5
{
width: 926px;
}
.style6
{
height: 53px;
width: 926px;
}
</style>
<link href="StyleSheet.css" rel="stylesheet" type="text/css" />
</head>
<body>
<form id="form1" runat="server">
<div>
<table border="1" style="width: 100%; height: 598px;">
<tr>
<td class="style6">
<esri:Toolbar ID="Toolbar1" runat="server" BuddyControlType="Map"
Group="Toolbar1_Group" Height="50px" ToolbarItemDefaultStyle-BackColor="White"
ToolbarItemDefaultStyle-Font-Names="Arial"
ToolbarItemDefaultStyle-Font-Size="Smaller"
ToolbarItemDisabledStyle-BackColor="White"
ToolbarItemDisabledStyle-Font-Names="Arial"
ToolbarItemDisabledStyle-Font-Size="Smaller"
ToolbarItemDisabledStyle-ForeColor="Gray"
ToolbarItemHoverStyle-BackColor="White" ToolbarItemHoverStyle-Font-Bold="True"
ToolbarItemHoverStyle-Font-Italic="True"
ToolbarItemHoverStyle-Font-Names="Arial"
ToolbarItemHoverStyle-Font-Size="Smaller"
ToolbarItemSelectedStyle-BackColor="White"
ToolbarItemSelectedStyle-Font-Bold="True"
ToolbarItemSelectedStyle-Font-Names="Arial"
ToolbarItemSelectedStyle-Font-Size="Smaller"
WebResourceLocation="/aspnet_client/ESRI/WebADF/" Width="400px">
<ToolbarItems>
<esri:Tool ClientAction="DragRectangle" DefaultImage="esriZoomIn.gif"
HoverImage="esriZoomInU.gif" JavaScriptFile="" Name="MapZoomIn"
SelectedImage="esriZoomInD.gif"
ServerActionAssembly="ESRI.ArcGIS.ADF.Web.UI.WebControls"
ServerActionClass="ESRI.ArcGIS.ADF.Web.UI.WebControls.Tools.MapZoomIn"
Text="Zoom In" ToolTip="Zoom In" />
<esri:Tool ClientAction="DragRectangle" DefaultImage="esriZoomOut.gif"
HoverImage="esriZoomOutU.gif" JavaScriptFile="" Name="MapZoomOut"
SelectedImage="esriZoomOutD.gif"
ServerActionAssembly="ESRI.ArcGIS.ADF.Web.UI.WebControls"
ServerActionClass="ESRI.ArcGIS.ADF.Web.UI.WebControls.Tools.MapZoomOut"
Text="Zoom Out" ToolTip="Zoom Out" />
<esri:Tool ClientAction="DragImage" DefaultImage="esriPan.gif"
HoverImage="esriPanU.gif" JavaScriptFile="" Name="MapPan"
SelectedImage="esriPanD.gif"
ServerActionAssembly="ESRI.ArcGIS.ADF.Web.UI.WebControls"
ServerActionClass="ESRI.ArcGIS.ADF.Web.UI.WebControls.Tools.MapPan" Text="Pan"
ToolTip="Pan" />
<esri:Command ClientAction="" DefaultImage="esriFullExt.gif"
HoverImage="esriFullExtU.gif" JavaScriptFile="" Name="MapFullExtent"
SelectedImage="esriFullExtD.gif"
ServerActionAssembly="ESRI.ArcGIS.ADF.Web.UI.WebControls"
ServerActionClass="ESRI.ArcGIS.ADF.Web.UI.WebControls.Tools.MapFullExtent"
Text="Full Extent" ToolTip="Full Extent" />
</ToolbarItems>
<BuddyControls>
<esri:BuddyControl Name="Map1" />
</BuddyControls>
</esri:Toolbar>
</td>
<td class="style4" rowspan="2">
<div>
<esri:Toc ID="Toc1" runat="server" BuddyControl="Map1" Height="191px" />
</div>
<asp:Label ID="Label1" runat="server" Text="查询图层:"></asp:Label>
<br />
<div id="layerListDiv">
<asp:DropDownList ID="DropDownList1" runat="Server" Height="16px" Width="153px"> </asp:DropDownList> </div>
<div id="fieldListDiv">
</div>
</td>
</tr>
<tr>
<td class="style5">
<esri:MapResourceManager ID="MapResourceManager1" runat="server">
<ResourceItems>
<esri:MapResourceItem Definition="<Definition DataSourceDefinition="In Memory" DataSourceType="GraphicsLayer" Identity="" ResourceDefinition="" DataSourceShared="True" />"
DisplaySettings="visible=True:transparency=0:mime=True:imgFormat=PNG8:height=100:width=100:dpi=96:color=:transbg=False:displayInToc=True:dynamicTiling="
LayerDefinitions="" Name="Selection" />
<esri:MapResourceItem Definition="<Definition DataSourceDefinition="localhost" DataSourceType="ArcGIS Server Local" Identity="To set, right-click project and 'Add ArcGIS Identity'" ResourceDefinition="Layers@NorthAmerica" DataSourceShared="True" />"
DisplaySettings="visible=True:transparency=0:mime=True:imgFormat=PNG8:height=100:width=100:dpi=96:color=White:transbg=True:displayInToc=True:dynamicTiling="
LayerDefinitions="" Name="NorthAmericaMap" />
</ResourceItems>
</esri:MapResourceManager>
<esri:Map ID="Map1" runat="server" Height="454px" InitialExtent="Full"
MapResourceManager="MapResourceManager1" Width="922px">
</esri:Map>
</td>
</tr>
</table>
</div>
<p>
<esri:ContextMenu ID="ContextMenu1" runat="server" BackColor="White"
onitemclicked="ContextMenu1_ItemClicked" />
</p>
</form></body>
<script type="text/javascript" language="javascript">
function window.onload()
{
GetResouceContent();
}
</script>
</html> 源代码这样的,在IE中会执行GetResouceContentv(),
但是在chome中就不会执行
//代码内容
}