问题
I am developing a web application that is intended to run solely on an embedded device with its own web browser.
This device browser is represented as being similar to (but not an exact match for) Firefox in the documentation.
I would like to use the jQuery library to ease development.
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");
});
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>
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.
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.
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)
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?
回答1:
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.
Type in a URL like this: javascript:alert($);
You should get an alert that has a function definition in it. But, this could not work in your device's browser.
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.
Good luck!
回答2:
Using the advice from @Adam Terlson I determined that this appears to be an issue with the jQuery library loading in the first place, likely due to the ANT Galio embedded browser, so I opened a more specific question related to that specific browser: How do I get jQuery working on the ANT Galio browser?
来源:https://stackoverflow.com/questions/6101001/how-do-i-troubleshoot-jquery-not-working-on-a-page-loaded-on-an-embedded-device