onload事件觸發的function,可以寫在body的onload事件中。
例如:
<body onLoad="init();">
<div id="content">It is a book !</div>
</body>
也可以寫在javascript中:
window.onload = onloadHandler
如下:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html><!-- InstanceBegin template="/Templates/main.dwt.php" codeOutsideHTMLIsLocked="false" --><head>
<!-- InstanceBeginEditable name="doctitle" -->
<title>建立原料名稱</title>
<script type="text/javascript" language="javascript">
var LaunchElement = null;
var SortColumn = -1;
var SortOrder = 1;
if (document.addEventListener)
{
document.addEventListener("DOMContentLoaded", onloadHandler, false);
}
else
{
window.onload = onloadHandler;
}
function onloadHandler()
{
tSeq=getQueryString("modseq");
if (!empty(tSeq)){
try
{
parent.document.getElementById("dtable").style.visibility="hidden";
parent.document.getElementById("extable").style.visibility="hidden";
parent.document.getElementById("metable").style.visibility="visible";
parent.document.getElementById("modCancel").style.visibility="visible";
}
catch (ex) {}
} else{
try
{
parent.document.getElementById("dtable").style.visibility="visible";
parent.document.getElementById("extable").style.visibility="visible";
parent.document.getElementById("metable").style.visibility="hidden";
parent.document.getElementById("modCancel").style.visibility="hidden";
}
catch (ex) {}
}
try
{
document.getElementById("TagTable").style.width = window.frameElement.parentNode.clientWidth + "px";
document.getElementById("FileTable").parentNode.style.width = window.frameElement.parentNode.clientWidth + "px";
}
catch (ex) {}
document.getElementById("se_cat").onchange = function (e) {onchangeHandler(e);};
}
function onchangeHandler(e)
{
var srcElement = window.event ? window.event.srcElement : e.target;
if (srcElement.tagName == "SELECT")
{
doSubmit();
}
}
function doSubmit()
{
var QueryString = "?";
QueryString += "se_cat=" + encodeURIComponent(document.getElementById("se_cat").value);
window.location.replace("new_material.php"+QueryString);
}
</script>