我有2个文件: - Parent.aspx和Child.aspx
Parent.aspx如下: -
<%@ Page Language="vb" AutoEventWireup="false" Codebehind="Parent.aspx.vb" Inherits="oneNetASP.Parent"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<title>Testing</title>
<meta name="GENERATOR" content="Microsoft Visual Studio .NET 7.1">
<meta name="CODE_LANGUAGE" content="Visual Basic .NET 7.1">
<meta name="vs_defaultClientScript" content="JavaScript">
<meta name="vs_targetSchema" content="http://schemas.microsoft.com/intellisense/ie5">
<script type="text/javascript">
window.onload=function(event)
{
if (window.event) // IE
{
document.getElementById("linkid").click();
}
else
{
document.getElementById("linkid").onclick();
}
}
function doOnClick()
{
document.getElementById("linkid").href = 'Child.aspx';
}
</script>
</HEAD>
<body>
<form id="Form1" method="post" runat="server">
<a id="linkid" href="" onclick="doOnClick();">Next Page</a>
</form>
</body>
</HTML>
Child.aspx如下: -
<%@ Page Language="vb" AutoEventWireup="false" Codebehind="Child.aspx.vb" Inherits="oneNetASP.Child"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<title>Testing</title>
<meta name="GENERATOR" content="Microsoft Visual Studio .NET 7.1">
<meta name="CODE_LANGUAGE" content="Visual Basic .NET 7.1">
<meta name="vs_defaultClientScript" content="JavaScript">
<meta name="vs_targetSchema" content="http://schemas.microsoft.com/intellisense/ie5">
</HEAD>
<body>
Hello, How r u?
</body>
</HTML>
当我在IE中运行Parent.aspx时,它会自动加载Child.aspx页面。 但是在Firefox中,当我运行Parent.aspx页面时,它不会调用Child.aspx页面。但是,如果我单击parent.aspx页面上的链接,它将加载child.aspx页面。
当我在firefox中运行Parent.aspx页面时,请帮我加载Child.aspx页面。
答案 0 :(得分:0)
window.onload=function(event)
{
if (window.event) // IE
{
document.getElementById("linkid").click();
}
else
{
var clickedElement = document.getElementById("linkid");
if (typeof clickedElement.onclick == "function")
{
clickedElement.onclick.apply(clickedElement);
}
}
}