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 found a problem. I put this control in masterpage. Then a page uses this masterpage.
It is found that when the page loading is not over and the menu is clicked quickly, a unique IE error will be reported.
Google, there are many such errors. Some people encounter 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 use firefox for browsing, but there is no problem. IE is a very common error. It usually occurs when the document has not been loaded and the script dynamically modifies the document status.
For asp.net menu, I checked the automatically generated code. asp.net will dynamically generate several axd files, which are actually js files. There is similar code.
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 );
}
}
Hehe, indeed there is a dynamic appendchild code. In fact, this practice is not rigorous, The MS write code, sometimes will ignore some problems.
What should I do if the document has not been loaded and the appendchild triggers it?
Well, when I clicked it very quickly, it happened to be the case of concurrency. similar to thread synchronization. this is also why IE reports an error. the concurrency control for modifying the document Status in firefox may be different from that in ie.
How can we modify it next?
1. You can place the menu in a div. First, set 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"
}
}
In this way, we can solve the problem.
If you can modify the script, you can add a Defer attribute to the script.