简体   繁体   English

从Web服务下载文件后,使用Web浏览器控件在html中播放Java脚本时的奇怪行为

[英]Odd behavior on playing java script in a html using web browser control after download a file from the web service

For last 2-3 weeks i am looking for a reason behind my problem. 在过去的2-3周中,我一直在寻找问题背后的原因。 But unfortunately i could not found anything needed. 但是不幸的是我找不到任何需要的东西。

It is a Windows Phone Book reader application i am creating using c# and xaml . 这是我正在使用c#和xaml创建的Windows Phone Book阅读器应用程序。

For that i need to download book file from the web service and extract and save audio,image and html data from it. 为此,我需要从Web服务下载书籍文件,并从中提取并保存音频,图像和html数据。 All data are stored in local folder. 所有数据都存储在本地文件夹中。

The main functionality is that we can see highlighting of texts with the corresponding audio plays. 主要功能是我们可以看到带有相应音频播放的文本突出显示。 And the high lighting functionality is done by java script function. 高亮度功能是由Java脚本功能完成的。

My problem is that the highlighting text is delaying some times and it doesn't meet with it's audio. 我的问题是,突出显示的文本延迟了一段时间,并且与音频不符。 And this is happening on the session where the book data downloaded from network or where download operation took place. 这是在从网络下载图书数据或进行下载操作的会话中发生的。

Is there anything related to network download operation can prevent/delay the execution of java script function ? 是否有任何与网络下载操作有关的事情可以阻止/延迟Java脚本功能的执行?

Can network download operation makes any impact on Web browser control ? 网络下载操作可以对Web浏览器的控制产生影响吗?

If you use callback functions in JS the right way the function of eg. 如果您在JS中使用回调函数,例如eg的正确方法。 highlighting will start only after the loading is complete. 仅在加载完成后才开始突出显示。 This issue reminds me of a few things I have seen while toying with nodeJS that uses about 80% async functions and a loop. 这个问题让我想起了我在使用nodeJS时看到的一些事情,它使用了大约80%的异步功能和一个循环。 However, if you want to get things structured in JS you might want to have a look at RequireJS, but async func calls can be used anyways.. 但是,如果您希望使用JS构建结构,则可能需要看一下RequireJS,但是仍然可以使用异步func调用。

function highlightElement(element, function(){
  // Load document here, once this operation is done, highlighting will start
}) {
  element.addClass('active');
};

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM