Subj : RE: Stopping Script Execution To : netscape.public.mozilla.jseng From : "Damian Slee" Date : Thu Sep 25 2003 08:54 am initialisation JS_SetBranchCallback(m_Context, BranchCallback); callback #define SCRIPT_TIMEOUT 3000 JSBool BranchCallback(JSContext *Context, JSScript *Script) { JSObject *global = JS_GetGlobalObject(Context); if (global) { if (m_scriptTimer.Expired(SCRIPT_TIMEOUT)) { JS_ReportError(Context,"Script execution halted, possible infinite loop"); return JS_FALSE; } } } return JS_TRUE; } -----Original Message----- From: JZ [mailto:jamilz@citlink.net] Sent: Thursday, 25 September 2003 7:04 AM To: mozilla-jseng@mozilla.org Subject: Stopping Script Execution Lets say we have a script like: for (var i = 0; i < 1000000; i++) { // just a waste of time } I want to be able to stop the execution of this script. I know if the script is calling one of my native C functions, I can return JS_FALSE to stop the script, but how do I stop a script such as the one above that doesn't call a native function? If I close the context/runtime I get an exception. JZ _______________________________________________ Mozilla-jseng mailing list Mozilla-jseng@mozilla.org http://mail.mozilla.org/listinfo/mozilla-jseng .