Asp.net menu "Operation aborted"

Source: Internet
Author: User
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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.