ClientScript.RegisterStartupScript生成的是js脚本<script>xxxxx</script>,位置 在 </form>上面,与页面展现 关系不大,但是
有时候不能就生成到这儿,因为我有的代码要去操作父页面中的元素,就有IE6和IE7的兼容性问题,如果是在</form>标签前面的话,在IE6、IE7中就会有网站无法打开的现象。而且另一中情况,在页面没有Form标签的情况,是无法弹出的。
解决方案:
在aspx页面加个标签(不影响样式的),然后再cs页面拼好脚本给标签付过去就行了。
aspx:
<asp:Literal runat="server" ID="tanchu"></asp:Literal>
aspx.cs:
string tishi = "<script language='javascript' defer>alert('提示内容');window.location.href='carlist.aspx';</script>";
tanchu.Text = tishi;