English 中文(简体)
在Javascript 和Calileo 功能 之后创建塔
原标题:Create Script Tag Within Javascript and Call Function Right After
  • 时间:2011-11-21 17:08:37
  •  标签:
  • javascript

我有某些法典,我试图在文字档案中添加文字档案,然后在文字档案中打电话。 该守则是:

function includeJS(p_file) {
    var v_js  = document.createElement( script );
    v_js.type =  text/javascript ;
    v_js.src = p_file;
    document.getElementsByTagName( head )[0].appendChild(v_js);
}

function checkFlash(){
    includeJS( /scripts/swfobject.js );
    var playerVersion = swfobject.getFlashPlayerVersion();
    return playerVersion.major;
}

alert(checkFlash());

问题在于它试图获得参与者版本的盘点。 我检查了大火,这显示文字被装上,读书正确无误,因此它不是一个道路问题。

I thought that maybe it was a delay issue in the includeJS function, but when I would that code in before the alert without it being a function, it still gives the same problem.

关于我如何做这样的事情的想法?

感谢。

最佳回答

我认为,你的问题是,在你试图检查角色版本之前,文字档案没有完成装货(与你原先想象的一样)。 您不妨尝试:

function includeJS(p_file, callback) {
    var v_js  = document.createElement( script );
    v_js.type =  text/javascript ;
    v_js.src = p_file;

    v_js.onreadystatechange = callback;
    v_js.onload = callback;

    document.getElementsByTagName( head )[0].appendChild(v_js);
}

function checkFlash(){
    var playerVersion;
    includeJS( /scripts/swfobject.js , function () {
        var playerVersion = swfobject.getFlashPlayerVersion();
        alert(playerVersion.major);
    });
}

checkFlash();

这是对similar问题的答复中提出的解决办法。

问题回答

暂无回答




相关问题
selected text in iframe

How to get a selected text inside a iframe. I my page i m having a iframe which is editable true. So how can i get the selected text in that iframe.

How to fire event handlers on the link using javascript

I would like to click a link in my page using javascript. I would like to Fire event handlers on the link without navigating. How can this be done? This has to work both in firefox and Internet ...

How to Add script codes before the </body> tag ASP.NET

Heres the problem, In Masterpage, the google analytics code were pasted before the end of body tag. In ASPX page, I need to generate a script (google addItem tracker) using codebehind ClientScript ...

Clipboard access using Javascript - sans Flash?

Is there a reliable way to access the client machine s clipboard using Javascript? I continue to run into permissions issues when attempting to do this. How does Google Docs do this? Do they use ...

javascript debugging question

I have a large javascript which I didn t write but I need to use it and I m slowely going trough it trying to figure out what does it do and how, I m using alert to print out what it does but now I ...

Parsing date like twitter

I ve made a little forum and I want parse the date on newest posts like twitter, you know "posted 40 minutes ago ","posted 1 hour ago"... What s the best way ? Thanx.

热门标签