如何解决jQuery无法在嵌入式设备的浏览器中加载的页面上运行的问题? [英] How do I troubleshoot jQuery not working on a page loaded on an embedded device's browser?

查看:110
本文介绍了如何解决jQuery无法在嵌入式设备的浏览器中加载的页面上运行的问题?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发一个Web应用程序,该应用程序只能在具有自己的Web浏览器的嵌入式设备上运行.

I am developing a web application that is intended to run solely on an embedded device with its own web browser.

此设备浏览器在文档中表示与Firefox类似(但不完全匹配).

This device browser is represented as being similar to (but not an exact match for) Firefox in the documentation.

我想使用jQuery库简化开发.

I would like to use the jQuery library to ease development.

考虑到这一点,我使用jQuery创建了一个简单的测试应用程序,在Firefox中对其进行了测试(它可以正常工作),然后尝试在该设备上运行它,发现只有非jQuery JavaScript可以运行(我得到了JavaScript警报,而不是jQuery警报.)

With this in mind I created a trivial test application using jQuery, tested it in Firefox (it works fine) and then tried running it on the device, where I found that only the non-jQuery JavaScript runs (I get the JavaScript alert but not the jQuery alert).

下面是我正在测试的脚本:

Below is the script I'm testing with:

window.onload = function() {
    alert("JavaScript works");
};


$(function() {
    alert("jQuery works");
});

然后使用<head>中的以下内容将脚本包含在html页面中:

And I'm including the script in my html page using the following in <head>:

<script type="text/javascript" src="jquery.js"> </script>
<script type="text/javascript" src="myscript.js"> </script>

我不太确定如何开始对此进行故障排除.我已经阅读了设备浏览器的文档,但没有找到用于对其进行故障排除的任何功能(例如控制台).我已经通过Wireshark并通过查看Web服务的日志来确认设备浏览器正在按预期加载jquery脚本.

I am not really sure how to start troubleshooting this. I've read through the documentation for the device browser and have not found any facilities for troubleshooting it (e.g. a console). I have confirmed via Wireshark and by looking at the log of the web service that the jquery script is being loaded by the device browser as expected.

我将与设备制造商联系,以查看他们是否会/可以提供帮助,但我希望我缺少在SO社区的帮助下自行解决此问题的某些方法.这是我的第一个认真的Web应用程序,因此我的Web调试技能还不如我的C#/.NET调试技能那么发达.

I will contact the device manufacturer and see if they will/can help but I'm hoping that I'm missing some method of troubleshooting this on my own with the help of the SO community. This is my first serious web application so my web debugging skills are not nearly as developed yet as say my C#/.NET debugging skills.

以下是一些有用或可能无用的信息.如果有什么有用的东西我省略了,请告诉我,我将其添加.

Below is some information which may or may not be useful. If there is anything useful I omitted please let me know and I'll add it.

以下是设备浏览器文档的摘录,列出了浏览器支持的标准.

Here is an excerpt from the device browser documentation listing the standards supported by the browser.

HTTP/S | 1.1 | 
HTML | 4.01 |  
XHTML | 1.0 | Requires following HTML compatibility guidelines.
XML DOM Level 2 | N/A
CSS | Level 2.1 |  
JavaScript | ECMAScript v3 |  
AJAX | N/A | Ajax is an architecture, not a specific technology. It requires that an object be present, covered under sections below.

这是嵌入式浏览器中的User-Agent字符串:

Here is the User-Agent string from the embedded browser:

Mozilla/5.0 (compatible; ANTGalio/2.1.19.12.020.2.0.00; vxWorks-6.3)

该Web应用程序由作为Windows服务运行的独立WCF Web服务托管.

The web application is being hosted by a standalone WCF web service run as a Windows Service.

那么有人会看到我的问题是什么,或者对我接下来要解决的问题有任何建议吗?

So does anybody see what my issue is or have any suggestions for what I should do next to troubleshoot it?

推荐答案

我认为您很难在没有控制台的情况下对其进行测试.我唯一想到的就是确保定义了$.没有控制台,我唯一想到的方法就是通过URL.

I think you're pretty hard-pressed to test this without a console. The only thing that I can think of is to make sure that $ is defined. Without a console, the only way I can think to do this is via the URL.

输入如下网址:javascript:alert($);

您应该收到其中包含函数定义的警报.但是,这在您设备的浏览器中无法使用.

You should get an alert that has a function definition in it. But, this could not work in your device's browser.

一旦确定实际上已经加载了jQuery,就可以开始在页面上查找可能导致代码无法运行的其他JavaScript错误.您可以尝试将jQuery与兼容性库结合使用.

Once you've determined that jQuery is in fact loaded, you can start to look for other javascript errors on the page that might be preventing your code from running. You might try using jQuery with the compatibility library as a last resort.

祝你好运!

这篇关于如何解决jQuery无法在嵌入式设备的浏览器中加载的页面上运行的问题?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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