日期:2014-05-16  浏览次数:20320 次

javascript语句执行的怪问题?
最近做一个在XML里使用javascript调用远程Web Services的程序,可是我遇到了一个怪问题:
<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet href="styles/common.xsl" type="text/xsl"?>
<html xmlns:u="http://housecall.trendmicro.com/xmlns/ui"
xmlns:locale="http://my.commons/XSL/PreProcess/Locale">
<head>
<u:header>
<locale:title>Trend Micro HouseCall 6.6 Example UI</locale:title>
</u:header>

<!-- Load the shared JavaScript code for the context pages -->
<script language="javascript" src="page.js"/>

<!-- Define the event listeners and start the system detection -->
<script language="javascript"><![CDATA[
window.handleKernelSelect = function(el) {
var show = el.value.indexOf("native") == -1;
var ctx = this.api.getContext();

// Set the current selection in the kernel
ctx.setOption("set-implementation", el.value);

// Show java alerts if necessary
if(!ctx.getBooleanOption("system-java-enabled"))
document.getElementById("no-java").style.display = show ? "block" : "none";
else if(!ctx.getBooleanOption("system-java-version-valid"))
document.getElementById("outdated-java").style.display = show ? "block" : "none";
}

window.initialize = function(api) {

if(this.UIInfo.getAttribute("boolean.cs.webcontent.skip.termsofuse") == "true" )
  window.api.setOption("accept-terms-of-use", "true" );


// Set the initial values in the form
with(document.forms['kernelSelect']) {
elements['locale'].value = decodeUrlParameters()["locale"];
elements['accept-terms-of-use'].checked =
api.getContext().getBooleanOption("accept-terms-of-use");
}


// Load the terms of use
this.UIInfo.termsElement = document.forms['kernelSelect'].elements['terms-of-use'];
this.UIInfo.windowRef = this;
this.UIInfo.loadTermsOfUse(function(UIInfo, content, code) {
if(code == 200)
UIInfo.termsElement.value = content;
else if(code >= 400 && code <= 505)
UIInfo.termsElement.value = "FATAL: Failed with:" + code;
else
UIInfo.windowRef.loadTermsOfUse(); // retry
});

// Register Event Handlers
api.addEvent(window, "onsystemdetectionfinished", function(source) {
var el = document.forms['kernelSelect'].elements['implSelect'];

// Register the java alerts hide and show handler
for(var i = 0; i < el.length; i++) {
el[i].onclick = function() {
source.handleKernelSelect(this);
}
}

// Preselect the best option
var preSelImpl = source.selectedImplementation;
for(var i = 0; i < el.length; i++)
if(el[i].disabled == false && (
preSelImpl == null || el[i].value == preSelImpl
)) {
el[i].checked = true;
source.handleKernelSelect(el[i]);
break;
}

// Enable the start button
document.forms['kernelSelect'].elements['start'].disabled = false;
});

api.addEvent(window, "onimplementationdetected", function(source, implementation) {
var el = document.forms['kernelSelect'].elements['implSelect'];
el = ( implementation.indexOf("native") != -1 ? el[0] : el[1] );
el.value = implementation;
el.disabl