怎么一打开页面就执行weather.do这个文件?

来源:百度知道 编辑:UC知道 时间:2024/06/30 16:59:42
<body align="left" onload="submit()">
上海天气预报:<br />
<form action="/wapSearch/weather/weather.do" method="post" name="weather">
<input id="city" name="city" type="hidden" value="" />
${time}<br />
<#if (resultDom?exists)>
<#if (resultDom.infList?exists)>
<#assign infoList = resultDom.infList>
<#list infoList as item>
${item}<br />
</#list>
</#if>
</#if>
</form>
</body>

我进页面自动提交的,但是怎么不执行weather.do这个文件???
怎么才能一打开页面就执行weather.do这个文件?

纠正一下,weather.do不是一个文件,是一个请求~

首先,你在<body align="left" onload="submit()"> 里,没有标明是哪个form去submit,所以要写成weather.submit(),其中weather是form的id,

其次,你在body的onload事件里处理,也就是说,还没加载完页面就要处理,当然会【可能】出错,需要【缓】执行,即把它放到页面的最后:
...
....
.....
</form>
<script type="text/jabascript">
weather.submit();
</script>
</body>

这样就可以了~~