简体   繁体   English

JavaScript生成的网页问题

[英]JavaScript generated web page issue

I have a problem with javascript generated web page. 我用javascript生成的网页有问题。 I have a web page on the internet that is generated by javascript. 我在Internet上有一个由javascript生成的网页。 I am working on changing a web page using wpf web browser control. 我正在使用wpf Web浏览器控件更改网页。 I have to make some changes to the web page by inserting jquery, and changing css and hiding some elements. 我必须通过插入jquery并更改CSS并隐藏一些元素来对网页进行一些更改。

Here is the issue. 这是问题。

Application works ok most of the time, but sometimes, for reasons unknown, it does not change the css or hides the elements. 应用程序在大多数情况下都可以正常运行,但是有时由于未知原因,它不会更改CSS或隐藏元素。 I presume that it has something to do with the javascript that actually generates the page. 我认为这与实际生成页面的javascript有关。 My code is executed, but no changes are made, so I presume that the script cannot find the elements in the page because they do not exist in the page, at the time of the execution of my scripts. 我的代码已执行,但未进行任何更改,因此我认为脚本无法在页面中找到元素,因为在执行脚本时,页面中不存在这些元素。 This is just an assumption. 这只是一个假设。

I need help resolving this issue. 我需要解决此问题的帮助。 I have tried delaying the execution of my scripts for n seconds, waiting for body.ready, document.ready and window.ready, but nothing helped. 我尝试将脚本的执行延迟n秒钟,等待body.ready,document.ready和window.ready,但没有任何帮助。 Also, I use wpf web browsers LoadCompleted event, but... From time to time, the script simply makes no effect on the page. 另外,我使用wpf Web浏览器的LoadCompleted事件,但是...有时,该脚本对页面完全无效。 Did somebody have this issue, does anyone have any idea how to solve it? 有人遇到过这个问题吗,有人知道如何解决吗?

Thank you very much in advance... 提前非常感谢您...

When building single page apps, always use a framework like Backbone or Sammy.js together with Mustachejs (or Hogan.js) for templating. 在构建单页应用程序时,请始终使用BackboneSammy.js之类的框架与Mustachejs(或Hogan.js)一起进行模板化。

Since we don't have any code to look at, if you're using jQuery, I suggest you check out .live() and .on() for attaching event handlers to elements you plan on loading into a div (making them clickable) etc. 由于我们没有任何代码可看,因此,如果您使用的是jQuery,建议您检查.live().on()以便将事件处理程序附加到计划加载到div的元素上(使它们可单击) )等

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

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