About page refresh or calling method things get no element information or a transposition thinking of missing object error settimeout use

Source: Internet
Author: User

These two days customer demand can not be fixed down, do idlers for a long time, rather to tidy up the recent encounter some small trouble.

Business:

Scene One,

Recently in the process of the development of the use of Baidu's rich client text editor (Ueditor)---This is a powerful text editor,

Now need: When this page opens, you need to write back the last edited information to this text editor, and the method used here is to ueditor the given method. This editor is also displayed in nested pages using an IFRAME.

1   //The HTML code is displayed in the editor. 2     functioninserthtml (value) {3SetContent ("");4Ue.geteditor (' newscontent '). ExecCommand (' inserthtml '), value)5     }6     //gets the HTML code for the editor. 7     functiongetcontent () {8        returnUe.geteditor (' Newscontent '). GetContent ();9     }Ten     //Sets the editor content, which is used in non-HTML form to set the editor to NULL, or you can use Inserthtml (""); One     functionsetcontent (isappendto) { AUe.geteditor (' Newscontent '). SetContent (isappendto); -}
get and Write editor content methods

When I use SetContent (data) on a single front page to write to the database, I found that when the page refresh is not every time after the successful writing to the text editor, then the problem, why not every time the success, after debugging found no errors reported .... Tried some ways, and later found that when the page load is not directly using the method defined in the IFRAME sub-page, it is necessary to call the relevant method after the current page is fully loaded, and when the data is written here, add settimeout to solve the problem perfectly.

1 setTimeout (function() {2  ewebeditor.setcontent (content); 3 },10004         5          6         
Resolving code

Scenario Two,

Now demand: I opened a sub-page (a) on the parent page through the jquery plugin Colorbox, while doing the operation on this page because I do not want to continue to open the new sub-page, so I use the parent.$ here. Colorbox opens a new Colorbox (b) from the parent page to replace the current sub-page, and when the B-page operation is completed I need to switch to a child page A that was originally opened by the parent page by a method set on the parent page.

At this time I can be universal to get to the parent page of all the information, but also to achieve the basic function, but in the browser below will be reported a SCRIPT5007: Missing object error, the code is written correctly, a page normal use, b page can also work properly, The browser will report this exception only when I jump to page A through the parent page method on page B, but can jump to page B. Think a good long time of thinking also tried a lot of methods can not solve this problem, and later found that when I issue the event if there is a pause, that is, Alert prompt box does not close quickly when this error will not happen, this is I think of settimeout, a use sure enough no longer appear this mistake.

And now I'm still struggling with the question of why,,,,

SetTimeout (function() {  parent.$ ("#btn_upd"). Click ();},
Resolving code

In fact, on the parent page to open another page, the current page should be closed. Or is it just that there is a display that is overwritten, and that the method can be called after the settimeout loading is complete?

About page refresh or calling method things get no element information or a transposition thinking of missing object error settimeout use

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.