* Indicates if script execution is necessary and/or possible.
*
* @return <code>true</code> if the script should be executed
*/
private boolean isExecutionNeeded() {
final SgmlPage page = getPage();
// If JavaScript is disabled, we don't need to execute.
if (!page.getWebClient().isJavaScriptEnabled()) {
return false;
}
//If innerHTML or outerHTML is being parsed
if (page instanceof HtmlPage && ((HtmlPage) page).isParsingHtmlSnippet()) {
return false;
}
// If the script node is nested in an iframe, a noframes, or a noscript node, we don't need to execute.
for (DomNode o = this; o != null; o = o.getParentNode()) {
if (o instanceof HtmlInlineFrame || o instanceof HtmlNoFrames || o instanceof HtmlNoScript) {
return false;
}
}
// If the underlying page no longer owns its window, the client has moved on (possibly
// because another script set window.location.href), and we don't need to execute.
if (page.getEnclosingWindow() != null && page.getEnclosingWindow().getEnclosedPage() != page) {
return false;
}
// If the script language is not JavaScript, we can't execute.
if (!isJavaScript(getTypeAttribute(), getLanguageAttribute())) {