Recently, a colleague used the Menu control of asp.net 2.0, which is one of the navigation controls of asp.net 2.0. Recently, I discovered a problem and placed this control in the masterpage. Then a page uses the masterpage.
I found that when the page is loaded It is not over. When you click on the menu quickly, an IE-specific error will be reported. Haha.
After searching Google, there are many errors like this. Some people also encountered similar errors when using asp.net menu. For example:
http://forums.asp.net/thread/1158791.aspx
http://forums.asp.net/thread/1159962.aspx
Similar programs can be browsed with firefox but there is no problem. This problem with IE is actually a very common mistake , it usually occurs when the document has not been loaded and a script dynamically modifies the document status.
For the asp.net menu, I looked at the code it automatically generates. Asp.net will dynamically generate several axd files. In fact, It is a js file. There is similar code in it.
if (!childFrame) {
childFrame = document.createElement("iframe");
childFrame.id = childFrameId;
childFrame.src = (data.iframeUrl ? data.iframeUrl : "about:blank");
childFrame.style.position = "absolute";
childFrame.style.display = "none";
childFrame.scrolling = "no";
childFrame.frameBorder = "0";
if (parent.tagName.toLowerCase() == "html") {
document.body.appendChild(childFrame);
}
else {
parent.appendChild(childFrame);
}
}
Haha, there is indeed a dynamic appendchild code. In fact, this approach is not rigorous. Codes written by MS sometimes ignore some problems.
What if the document has not been loaded yet and appendchild is triggered?
Haha, when I click Soon, it will be the occasion for concurrency. It is similar to thread synchronization. This is why IE will report an error. Firefox's concurrency control on document status modification may be different from IE.
How to modify it next?
1. You can put the menu in a div, first set the visibility to hidden.
2. After the document is loaded, set visibility to visible.
document.onreadystatechange=ShowMenu;
function ShowMenu()
{
if(document.readyState=="complete")
{
document.getElementById("DivOfMenu").style.visibility="visible"
}
}
That's it.
http://www.cnblogs.com/montaque/archive/2006/09/18/507639.html