问题与JavaScript正确加载和看到的一切 [英] Issues with javascript properly loading and seeing everything

查看:162
本文介绍了问题与JavaScript正确加载和看到的一切的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

好的,所以我有一个表单,通过另一个页面上的邮政编码小部件从请求中加载。该部件在新页面上立即填充两个表单域。我的问题是,我有一个相当复杂的一块闪存,有一个主要问题。我的flash本质上是一个饼图,在mouseOver事件和onClick事件在窗体复选框点亮。它的工作原理应该是这样的,除了最初加载页面的JavaScript不会看到预先填充的复选框并执行相应的高亮操作。这只发生在通过小部件填充的字段中,如果用户检查它工作正常的框,因为我有一个onClick事件处理程序连接到它。我写了一个预先选择的函数,它将决定这个字段是否被一个小部件预先选中,然后把它传递给下一行,正确地突出显示(只要我有警报功能)。现在,如果我在脚本中添加了一个警报(在每个函数中尝试它们都没有关系),它的工作原理与假设小部件立即填充的字段一样,并突出显示了相应的它是假设的领域。为什么只有一个警告框才能保持这个工作。这是最简单的警报,但删除,打破了我的代码。有任何想法吗?
这里是我的代码:(我把三个 * 放在我正在说的警报的两边)

pre > YAHOO.namespace(SOME.Place.QuoteRequest);
/ **
* @projectDescription SOME.util.QuoteRequest是所有引用请求相关函数的命名空间。这是报价请求页面的补充控制器。
* @return(object)函数在解析时自动执行并返回对其公共成员的引用
* @author web开发
* @version 1.0
* /
SOME .PLACE.QuoteRequest = function(){
/ **
*全局对象的快捷方式
* /
var Dom = YAHOO.util.Dom,Event = YAHOO.util。事件;

/ **
*将特殊错误处理程序添加到表单的邮政编码区域的功能。邮编错误显示在这个区域。此外,继续按钮有时是一个提交,有时是一个按钮,取决于表单的其余部分是否可见。
* @param {Object} frm引用请求表单对象
* /
var addQuoteRequestZipCodeHandler = function(frm){
if(frm.continueBtn){
.addListener(frm.submitBtn,click,function(e){
var errP = Dom.get(error),errMsg;
if(errP)errP.parentNode.removeChild(errP) ;
errMsg = SOME.util.Forms.validateFormField(this.zipCode.name,frm)
if(errMsg){
Event.preventDefault(e);
var p = document.createElement(p);
p.id =error;
var pText = document.createTextNode(errMsg);
p.appendChild(pText);
Dom.insertBefore(p,quoteZipLabel);
}
},frm,true);

}
};
$ b / **
*用于管理产品复选框和金融安全闪存盘之间交互的功能
* /
var CheckboxCollection = function()
{
var odom = Dom.get(finwheel);
var ochklist = Dom.getElementsByClassName(checkbox,input,odom);

var boolArray = [false,false,false,false,false,false];
var ctr = 0;

$ b $ for(var c = 0; c< ochklist.length; c ++)
{

switch(ochklist [c] .value。 toUpperCase())
{
caseAUTO:caseHOME:caseUMBRELLA:caseFARM:caseBUSINESS:// [Auto,Farm / Ranch / Crop,Home如果(ochklist [c] .checked&& ctr == 0)
{
*** alert(auto checked); ** *
boolArray [ctr] = ochklist [c] .checked;
ctr = ctr + 1;
}
break;
caseLIFE:// [Life]
if(ctr == 0)
{
boolArray [ctr] = false;
ctr = ctr + 1;

$ b $ if(ochklist [c] .checked&& ctr == 1)
{
boolArray [ctr] = ochklist [c] .checked ;
ctr = ctr + 1;
}
break;
caseDI:caseLTC:caseMEDSUP:// [Disability income,Medicare,Long term]
if(ctr == 1)
{
boolArray [ctr] = false;
ctr = ctr + 1;

$ b $ if(ochklist [c] .checked&& ctr == 2)
{
boolArray [ctr] = ochklist [c] .checked ;
ctr = ctr + 1;
}
break;
caseRETIREMENT:
if(ctr == 2)
{
boolArray [ctr] = false;
ctr = ctr + 1;

$ b $ if(ochklist [c] .checked&& ctr == 3)
{
boolArray [ctr] = ochklist [c] .checked ;
ctr = ctr + 1;
}
break;
caseEDUCATION:
if(ctr == 3)
{
boolArray [ctr] = false;
ctr = ctr + 1;

$ b $ if(ochklist [c] .checked&& ctr == 4)
{
boolArray [ctr] = ochklist [c] .checked ;
ctr = ctr + 1;
}
break;
caseFINANCIAL:
if(ctr == 4)
{
boolArray [ctr] = false;
ctr = ctr + 1;

$ b $ if(ochklist [c] .checked&& ctr == 5)
{
boolArray [ctr] = ochklist [c] .checked ;
ctr = ctr + 1;
}
break;
}
}

return boolArray;
};
$ b $ **
*添加处理程序以突出显示闪存盘的函数
* @param {Object} frm引用请求表单对象
* / $ b $如果你想要使用这个函数,你可以使用下面的代码来创建一个新的函数:b $ {$ b $ document.getElementById(finSection)。style.display =没有;
}
var imgs = Dom.getElementsByClassName(infoImg,I​​MG,quoteRequest);
var oflash = Dom.get(flashfsWheel);

for(var i = 0; i< imgs.length; i ++){
Event.addListener(imgs [i],'mouseover',function(e){
var titlenm = this.parentNode.id.substring(0,this.parentNode.id.indexOf(Title));
if(oflash)oflash.HighlightWheel(titlenm,true,TITLE);
});
Event.addListener(imgs [i],'mouseout',function(e){
var titlenm = this.parentNode.id.substring(0,this.parentNode.id.indexOf(Title ));
if(oflash)oflash.HighlightWheel(titlenm,false,TITLE);
});
}

//检查以确保预选复选框higlights对应的闪存块

var preselect = CheckboxCollection(); (f = 0; f

{
if(f = = 0)
oflash.HighlightWheel(property,预选[f],CLICK);
else if(f == 1)
oflash.HighlightWheel(income,preselect [f],CLICK);
else if(f == 2)
oflash.HighlightWheel(health,预选[f],CLICK);
else if(f == 3)
oflash.HighlightWheel(retirement,preselect [f],CLICK);
else if(f == 4)
oflash.HighlightWheel(education,预选[f],CLICK);






var secs = Dom.getElementsByClassName(formSection,DIV,frm );
Event.addListener(secs [2],click,function(e){
var elTarget = Event.getTarget(e);
var oflash = Dom.get(flashfsWheel );
if(elTarget.nodeName.toUpperCase()==INPUT){
elTarget.value = elTarget.value.toLowerCase();
//(pass elTarget.checked as parm来表示是否点亮或关闭)
if(elTarget.value ==auto|| elTarget.value ==home|| elTarget.value ==farm|| elTarget。 value ==umbrella|| elTarget.value ==business){
//调用闪存块来点亮属性块
var bool = CheckboxCollection();
if(oflash &&!bool [5])oflash.HighlightWheel(property,bool [0],CLICK);
if(bool [0])frm.needs [0] .value =property ;
else frm.needs [0] .value =;
}
else if(elTarget.value ==life){
//调用flash来点亮收入
var bool = CheckboxCollection();
if(oflash&&!bool [5])oflash.HighlightWheel(income,bool [1],CLICK);
if(bool [1])frm.needs [1] .value =income;
else frm.needs [1] .value =;
}
else if(elTarget.value ==di|| elTarget.value ==ltc|| elTarget.value ==medsup){
// call flash点亮健康片
var bool = CheckboxCollection();
if(oflash&&!bool [5])oflash.HighlightWheel(health,bool [2],CLICK);
if(bool [2])frm.needs [2] .value =health;
else frm.needs [2] .value =;
}
else if(elTarget.value ==retirement){
var bool = CheckboxCollection();
if(oflash&&!bool [5])oflash.HighlightWheel(retirement,bool [3],CLICK);
if(bool [3])frm.needs [3] .value =retirementSavings;
else frm.needs [3] .value =;
}
else if(elTarget.value ==education){
var bool = CheckboxCollection();
if(oflash&&!bool [5])oflash.HighlightWheel(education,bool [4],CLICK);
if(bool [4])frm.needs [4] .value =education;
else frm.needs [4] .value =;
}
else if(elTarget.value ==financial){
var bool = CheckboxCollection();
if(oflash)oflash.HighlightWheel(center,bool [5],CLICK);

if(!bool [5])
{
for(var f = 0; f {
if(f == 0)
oflash.HighlightWheel(property,bool [f],CLICK);
else if(f == 1)
oflash.HighlightWheel(income,bool [f],CLICK);
else if(f == 2)
oflash.HighlightWheel(health,bool [f],CLICK);
else if(f == 3)
oflash.HighlightWheel(retirement,bool [f],CLICK);
else if(f == 4)
oflash.HighlightWheel(education,bool [f],CLICK);



$ //调用闪光灯点亮整件物品


});

};
$ b $ **
*调用外部方法突出显示产品组以供财务需求使用闪存盘
* id是要突出显示的产品组标题的标识 - propertyTitle,incomeTitle,healthTitle,retirementTitle,educationTitle,financialTitle
* highlight是一个布尔值true或false来突出显示或关闭突出显示
* /
var highlightProductGroup = function(id,highlight){

if(highlight)
Dom.addClass(id,id +Highlight);
else
Dom.removeClass(id,id +Highlight);
};
$ b $ **
*函数启动引用请求表单的其他控制器
* @param {Object} frm引用请求表单对象
* /
var init = function(frm){
// add zip code handler
addQuoteRequestZipCodeHandler(frm);

if(frm.submitBtn){
var quoteRep = Dom.get(quoteRep);
if(quoteRep){
// add flash wheel
var output ='';
if(SOME.domain.indexOf(Cottonstates)!= -1){
output + ='< object height =370width =390data =flash / cottonStates / 5NeedsWheel2.swftype =application / x-shockwave-flashid =flashfsWheel>< param value =flash / SOMEStates / fiveNeedsWheel2.swfname =movie/>< param value =总是name =allowScriptAccess/>< param name =wmodevalue =window/>< a class =externalhref =http://www.adobe.com/go/getflashplayer >< img alt =Get Flash Playersrc =images / button_getFlashPlayer.gif/>< / a>< / object>';
//创建自动完成对象

SOME.widget.AutoComplete.init(quoteRep,acResults,/SiteController?url=/@AutoCompleteCS&forward=agentList.jsp,frm );
} else {
output + =' //创建自动完成对象
SOME.widget.AutoComplete.init(quoteRep,acResults,/SiteController?url=/@allRepresentativesAutoComplete&forward=agentList.jsp,frm);

if(document.getElementById(fsWheel))
document.getElementById(fsWheel)。innerHTML = output;

Dom.addClass([infoPos5,quoteEmailLabel,quoteEmail],noDisplay);


//添加电话或电子邮件处理程序
SOME.util.Forms.initPhoneEmailFields(frm.phone,frm.customerEmail,true);

//添加flash产品处理程序
addQuoteRequestProductHandlers(frm);

//添加提交处理程序
Event.addListener(frm.submitBtn,click,function(e){

var errs = SOME.util.Forms .validateForm(frm,{replaceErrorCodes:true,autoInsert:true,insertNode:Dom.getElementsByClassName(formSection)[0],showErrorHeader:true});

if(errs.length> 0 ){
Event.preventDefault(e);
window.scrollTo(0,0);
}
else {
this.businessSubject.value = this.businessSubject .value + frm.firstName.value ++ frm.lastName.value;
}
},frm,true);

}

};
$ b $ **
*返回此单例的公共成员
* /
返回{
init:init,
highlightProductGroup:highlightProductGroup
};
}();


解决方案

只是猜测,但可能是脚本在Flash对象加载之前正在执行并尝试与Flash进行通信,并且将警报放在那里,这会导致Flash执行足够长的时间来加载?



如果是这样,你有几个选择:
$ b $ ul

  • 延迟脚本的执行,直到Flash元素被加载。 b $ b立即执行脚本并将任何更改复选框写入Flash可在启动时读取的flashvar
  • 立即执行脚本,而不是调用Flash,而是存储这些值,并在加载并准备显示时使用ExternalInterface将Flash回调到页面。


  • Ok, so I have a form that loads from a request through a zip code widget from another page. THe widget populates two of the form fields immediately, on submit, on the new page. My problem is that I have a pretty complicated piece of flash on there as well that has ONE main issue. My flash is essentially a pie chart that lights up on mouseOver events and onClick events in the form check boxes. It works like it should except for the fact that on initially loading the page the javascript will not see the pre-populated check box and perform the corresponding highlighting action. This only happens in fields that are populated through the widgets, if a user checks the boxes it works fine as I have an onClick event handler attached to it. I wrote a preselect function that will determine if the field is preselected or not by a widget and then pass that on down the line to highlight it correctly (which it does as long as I have the alert functioning). Now, if I add an alert inside of the script (it doesn't matter where, as I've tried them in every function) it works like it suppose to and sees the fields that are populated immediately by the widget and highlights the corresponding field as it is suppose to. Why would an alert box be the only thing keeping this working. It is the simplest of alerts, but removing that breaks my code. Any ideas? Here is my code: (I placed three * on either side of the alert that I am talking about)

     YAHOO.namespace("SOME.Place.QuoteRequest");
    /**
     * @projectDescription SOME.util.QuoteRequest is the namespace for all quote request related functions. This is a supplemental controller for quote request pages.
     * @return  (object) function executes automatically when parsed and returns references to it's public members 
     * @author  web development
     * @version 1.0
     */
    SOME.PLACE.QuoteRequest = function () {
        /**
         * shortcuts to global objects
         */
        var Dom = YAHOO.util.Dom, Event = YAHOO.util.Event;
    
        /**
         * Function to add the special error handler to the zip code area of the form. Zip code errors display in this area. Also the continue button is sometimes a submit and sometimes a button depending on whether the rest of the form is visible.
         * @param {Object} frm the quote request form object
         */
        var addQuoteRequestZipCodeHandler = function(frm){
            if(frm.continueBtn){
                Event.addListener(frm.submitBtn, "click", function(e){                      
                    var errP = Dom.get("error"), errMsg;
                    if(errP) errP.parentNode.removeChild(errP);
                    errMsg = SOME.util.Forms.validateFormField(this.zipCode.name, frm)
                    if(errMsg){
                        Event.preventDefault(e);
                        var p = document.createElement("p");
                        p.id = "error";
                        var pText = document.createTextNode(errMsg);
                        p.appendChild(pText);
                        Dom.insertBefore(p, "quoteZipLabel");
                    } 
                },frm, true);           
    
            }
        };
    
        /**
         * Function to manage the interaction between the product checkboxes and the financial security flash wheel
         */
        var CheckboxCollection = function()
        {
                var odom = Dom.get("finwheel");         
                var ochklist = Dom.getElementsByClassName("checkbox", "input", odom);
    
                var boolArray = [false,false,false,false,false,false];
                var ctr = 0;
    
    
                for(var c = 0 ; c < ochklist.length ; c++)
                {
    
                    switch(ochklist[c].value.toUpperCase())
                    {
                        case "AUTO": case "HOME": case "UMBRELLA": case "FARM": case "BUSINESS": //[Auto , Farm/Ranch/Crop, Home/Reuters, Umbrella, business]
                            if(ochklist[c].checked && ctr == 0)
                            {
                                ***alert("auto checked");***
                                boolArray[ctr] = ochklist[c].checked;
                                ctr = ctr+1;
                            }
                            break;
                        case "LIFE":  // [Life]
                            if(ctr == 0)
                            {
                                boolArray[ctr] = false;
                                ctr = ctr+1;
                            }
    
                            if(ochklist[c].checked && ctr == 1)
                            {   
                                boolArray[ctr] = ochklist[c].checked;
                                ctr = ctr+1;
                            }
                            break;
                        case "DI": case "LTC": case "MEDSUP": // [disability income , Medicare , Long term]
                            if(ctr == 1)
                            {
                                boolArray[ctr] = false;
                                ctr = ctr+1;
                            }
    
                            if(ochklist[c].checked && ctr == 2)
                            {
                                boolArray[ctr] = ochklist[c].checked;
                                ctr = ctr+1;
                            }
                            break;
                        case "RETIREMENT":
                            if(ctr == 2)
                            {
                                boolArray[ctr] = false;
                                ctr = ctr+1;
                            }
    
                            if(ochklist[c].checked && ctr == 3)
                            {
                                boolArray[ctr] = ochklist[c].checked;
                                ctr = ctr+1;
                            }
                            break;
                        case "EDUCATION":
                            if(ctr == 3)
                            {
                                boolArray[ctr] = false;
                                ctr = ctr+1;
                            }
    
                            if(ochklist[c].checked && ctr == 4)
                            {
                                boolArray[ctr] = ochklist[c].checked;
                                ctr = ctr+1;
                            }
                            break;
                        case "FINANCIAL":
                            if(ctr == 4)
                            {
                                boolArray[ctr] = false;
                                ctr = ctr+1;
                            }
    
                            if(ochklist[c].checked && ctr == 5)
                            {
                                boolArray[ctr] = ochklist[c].checked;
                                ctr = ctr+1;
                            }
                            break;
                    }               
                }
    
            return boolArray;
        };
    
        /**
         * Function to add handlers to highlight the flash wheel
         * @param {Object} frm the quote request form object
         */
        var addQuoteRequestProductHandlers = function(frm){         
            if(document.URL.indexOf("@financialSecurityPlan") >= 0){
                document.getElementById("finSection").style.display = "none";
            }
            var imgs = Dom.getElementsByClassName("infoImg", "IMG", "quoteRequest");
            var oflash = Dom.get("flashfsWheel");       
    
            for(var i=0; i<imgs.length; i++){
                Event.addListener(imgs[i], 'mouseover', function(e){                                
                    var titlenm = this.parentNode.id.substring(0,this.parentNode.id.indexOf("Title"));
                    if(oflash) oflash.HighlightWheel(titlenm,"true","TITLE");
                });
                Event.addListener(imgs[i], 'mouseout', function(e){     
                    var titlenm = this.parentNode.id.substring(0,this.parentNode.id.indexOf("Title"));
                    if(oflash) oflash.HighlightWheel(titlenm,"false","TITLE");
                });
            }
    
           // Check to make sure pre-selected check box higlights corresponding flash pieces
    
            var preselect = CheckboxCollection();
            if(!preselect[5])
                        {
                            for(var f = 0 ; f < preselect.length ; f++ )
                            {
                                if(f == 0)
                                    oflash.HighlightWheel("property",preselect[f],"CLICK");
                                else if(f == 1)
                                    oflash.HighlightWheel("income",preselect[f],"CLICK");
                                else if(f == 2)
                                    oflash.HighlightWheel("health",preselect[f],"CLICK");
                                else if(f == 3)
                                    oflash.HighlightWheel("retirement",preselect[f],"CLICK");
                                else if(f == 4)
                                    oflash.HighlightWheel("education",preselect[f],"CLICK");                                
    
                            }
    
                        }
    
    
    
            var secs = Dom.getElementsByClassName("formSection", "DIV", frm);
            Event.addListener(secs[2], "click", function(e) {
                var elTarget = Event.getTarget(e); 
                var oflash = Dom.get("flashfsWheel");
                if(elTarget.nodeName.toUpperCase() == "INPUT"){
                    elTarget.value = elTarget.value.toLowerCase();
                    //(pass elTarget.checked as the parm to say whether to light up or turn off)
                    if(elTarget.value == "auto" || elTarget.value == "home" || elTarget.value == "farm" || elTarget.value == "umbrella" || elTarget.value == "business"){
                        //call flash piece to light up property piece
                        var bool = CheckboxCollection();
                        if( oflash && !bool[5] ) oflash.HighlightWheel("property",bool[0],"CLICK");
                        if(bool[0]) frm.needs[0].value = "property";
                        else frm.needs[0].value = "";
                    }               
                    else if (elTarget.value == "life"){
                        //call flash to light up income piece
                        var bool = CheckboxCollection();
                        if(oflash && !bool[5]) oflash.HighlightWheel("income",bool[1],"CLICK");
                        if(bool[1]) frm.needs[1].value= "income";
                        else frm.needs[1].value= "";
                    }
                    else if(elTarget.value == "di" || elTarget.value == "ltc" || elTarget.value == "medsup"){
                        //call flash to light up health piece
                        var bool = CheckboxCollection();
                        if(oflash && !bool[5]) oflash.HighlightWheel("health",bool[2],"CLICK");
                        if(bool[2]) frm.needs[2].value= "health";
                        else frm.needs[2].value= "";
                    }
                    else if(elTarget.value == "retirement"){
                        var bool = CheckboxCollection();
                        if(oflash && !bool[5] ) oflash.HighlightWheel("retirement",bool[3],"CLICK");
                        if(bool[3]) frm.needs[3].value= "retirementSavings";
                        else frm.needs[3].value= "";
                    }
                    else if(elTarget.value == "education"){
                        var bool = CheckboxCollection();
                        if(oflash && !bool[5] ) oflash.HighlightWheel("education",bool[4],"CLICK");
                        if(bool[4]) frm.needs[4].value= "education";
                        else frm.needs[4].value= "";
                    }
                    else if(elTarget.value == "financial"){                 
                        var bool = CheckboxCollection();                    
                        if(oflash) oflash.HighlightWheel("center",bool[5],"CLICK");
    
                        if(!bool[5])
                        {
                            for(var f = 0 ; f < bool.length ; f++ )
                            {
                                if(f == 0)
                                    oflash.HighlightWheel("property",bool[f],"CLICK");
                                else if(f == 1)
                                    oflash.HighlightWheel("income",bool[f],"CLICK");
                                else if(f == 2)
                                    oflash.HighlightWheel("health",bool[f],"CLICK");
                                else if(f == 3)
                                    oflash.HighlightWheel("retirement",bool[f],"CLICK");
                                else if(f == 4)
                                    oflash.HighlightWheel("education",bool[f],"CLICK");                             
    
                            }
                        }
    
                        //call flash to light up whole thing
                    }
                }
            });
    
        };
    
        /**
         * External method to call to highlight a product group for use by the financial needs flash wheel
         * id is the id of the product group title to highlight - propertyTitle, incomeTitle, healthTitle, retirementTitle, educationTitle, financialTitle
         * highlight is a boolean true or false to highlight or turn off highlight
         */
        var highlightProductGroup = function(id, highlight){
    
            if(highlight)
                Dom.addClass(id, id + "Highlight");
            else
                Dom.removeClass(id, id+ "Highlight");       
        };
    
        /**
         * function to kick off additional controllers for the quote request form
         * @param {Object} frm the quote request form object
         */
        var init = function(frm){       
            //add zip code handler
            addQuoteRequestZipCodeHandler(frm);
    
            if(frm.submitBtn){
                var quoteRep = Dom.get("quoteRep");
                if(quoteRep){
                    //add flash wheel
                    var output = '';
                    if(SOME.domain.indexOf("cottonstates") != -1){
                        output += '<object height="370" width="390" data="flash/cottonStates/fiveNeedsWheel2.swf" type="application/x-shockwave-flash" id="flashfsWheel"><param value="flash/SOMEStates/fiveNeedsWheel2.swf" name="movie"/><param value="always" name="allowScriptAccess"/><param name="wmode" value="window"/><a class="external" href="http://www.adobe.com/go/getflashplayer"><img alt="Get Flash Player" src="images/button_getFlashPlayer.gif"/></a></object>';
                        //create the autocomplete object
    
                        SOME.widget.AutoComplete.init(quoteRep, "acResults", "/SiteController?url=/@AutoCompleteCS&forward=agentList.jsp", frm );
                    }else{
                        output += '<object height="370" width="390" data="flash/financial/fiveNeedsWheel2.swf" type="application/x-shockwave-flash" id="flashfsWheel"><param value="flash/financial/fiveNeedsWheel2.swf" name="movie"/><param value="always" name="allowScriptAccess"/><param name="wmode" value="window"/><a class="external" href="http://www.adobe.com/go/getflashplayer"><img alt="Get Flash Player" src="images/button_getFlashPlayer.gif"/></a></object>';
                        //create the autocomplete object
                        SOME.widget.AutoComplete.init(quoteRep, "acResults", "/SiteController?url=/@allRepresentativesAutoComplete&forward=agentList.jsp", frm );   
                    }                                   
                    if(document.getElementById("fsWheel"))
                        document.getElementById("fsWheel").innerHTML = output;
    
                    Dom.addClass(["infoPos5", "quoteEmailLabel", "quoteEmail"], "noDisplay");
                }
    
                //add phone or email handler
                SOME.util.Forms.initPhoneEmailFields(frm.phone, frm.customerEmail, true);
    
                //add flash product handlers
                addQuoteRequestProductHandlers(frm);
    
                //add submit handler
                Event.addListener(frm.submitBtn, "click", function(e){          
    
                    var errs = SOME.util.Forms.validateForm(frm, {replaceErrorCodes: true, autoInsert : true, insertNode : Dom.getElementsByClassName("formSection")[0], showErrorHeader: true});                   
    
                    if(errs.length > 0){
                        Event.preventDefault(e);
                        window.scrollTo(0,0);
                    }
                    else{
                        this.businessSubject.value = this.businessSubject.value + frm.firstName.value + " " + frm.lastName.value;
                    }           
                },frm, true);           
    
            }
    
        };
    
        /**
         * return the public members of this singleton
         */
        return {
            init:init,
            highlightProductGroup:highlightProductGroup
        };
    }(); 
    

    解决方案

    Just a guess, but could it be that the script is executing and trying to communicate with Flash before the Flash object is loaded, and by putting the alert in there you're breaking the execution long enough for the Flash to load?

    If so you have a few options:

    • Delay the execution of the the script until the Flash element is loaded.
    • Execute the script immediately and write any changes to the checkboxes to a flashvar that Flash can read on startup
    • Execute the script immediately, but instead of calling to Flash, store the values and have Flash call back to the page using ExternalInterface when it is loaded and ready to display.

    这篇关于问题与JavaScript正确加载和看到的一切的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

    查看全文
    登录 关闭
    扫码关注1秒登录
    发送“验证码”获取 | 15天全站免登陆