I am using Firefox 21 built for Linux Mint. When trying to open an IndexedDB database from within a script tag I get an InvalidStateError. However, I do not get an error when trying to open a database from the JavaScript console.
The following code gives an error
<html>
<body>
<script src="http://code.jquery.com/jquery-1.10.0.min.js"></script>
<script type="text/javascript">
$(document).ready(function(){
indexedDB.open("MyNewDatabase");
});
</script>
</body>
</html>
while entering indexedDB.open("MyNewDatabase"); in the console properly returns an IDBOpenDBRequest object. Any ideas what might cause this strange behaviour?
I am aware of Invalid state Error in Firefox for Indexed Db and InvalidStateError while opening IndexedDB in Firefox, but both questions/answers could not help me figure out the problem.
This reply is probably too late to be useful, but have you checked the dom.indexedDB.enabled pref is true in about:config?
I ended up reading the Gecko indexedDB source code to discover that I had flipped that pref to false in the past for reasons unknown!
Have you tred passing in version as the second parameter to indexedDB.open? I recall some random conversation I found on the web where there was a decision to make it non optional and such. I believe spec says it defaults to 1 if not provided but you might want to at least see what happens.
In Chrome and Firefox...you must include the version number. In IE10...you must NOT. IE10 further uses the prefix 'msIndexedDB' and the use of transaction enumerations is likewise inconsistent with Microsoft. Some versions of IE use MS prefixed enum values, others use a string. Grrr.
Related
I'm seeing an Intl not available error in the JS console when my script runs the following code in Edge 15:
new Date().toLocaleDateString()
I'm a bit stumped by this. It is working just fine in Edge 14, and I can't find any reference to the internationalization API suddenly disappearing from Edge 15.
I'm not sure if this is the proper way to test it, but running window.hasOwnProperty("Intl") in the console actually returns true. To me this seems to indicate that Intl actually is there.
Anyone with more JS skills able to tell what is really going on here?
Make sure your JS code doesn't redefine standard Map class.
We had almost the same problem, but with Intl.Collator object instead. We couldn't use String.prototype.localeCompare("...", "locale") because of this.
You can look at this codepen in Edge 15 and in other browsers for explanation: https://codepen.io/kgorob/pen/pweaWV.
P.S.
I'm not sure your problem is because of Map class specifically, maybe it's some other standard JS class you are re-defining.
The problem is because of these lines in Chakracore code. Intl.js is javascript file that is used internally to perform various internationalization specific operations. Since Mapis used, over-writing it before Intl.js code executes (it is executed lazily), causes problem. This should be addressed soon.
As ksp's answer says, this is caused by Intl lazy-loading after Map is overwritten. Therefore, the easiest workaround is to just force it to initialise early, before other scripts run:
<html>
<head>
<script>Intl.DateTimeFormat</script>
...
Here is the issue in the Chakra repo: https://github.com/Microsoft/ChakraCore/issues/3189
I'm working with Dynamics CRM 2011 Online and trying to refactor some code that works on the Quote > Add Product page to also work on Order > Add Product. The problem is that when the page loads I get the error "Unable to get property 'getValue' of undefined or null reference."
I went into the IE console (tried both IE 9 and 10) and typed in what I believed to be the offending line:
Xrm.Page.getAttribute('ati_clin').getValue()
It complains with "Object doesn't support property or method 'getAttribute'". I also tried
document.getElementById('ati_clin')
but that too fails.
This doesn't make sense to me because I can use the HTML view of the developer console to find the object on the page and it's clearly there (no typo too). It also doesn't make sense that this statement fails in the console on both pages even though one of the pages runs properly at runtime and the other doesn't. Shouldn't it at least work on the page that does work at runtime?
After doing some research I think the following posting is the most relevant but I'm afraid it doesn't lead me to an answer seeing as how new I am to this: Xrm.Page.data is null
My question is why does the console return this error if the element clearly exists?
A handy trick when debugging a problem like this:
The Xrm.Page object lives in the context of a frame. If you want to use console in IE Developer tools without having to break in debug mode, you first have to point to the frame on the page.
Example:
frames[0].Xrm.Page.getAttribute('ati_clin').getValue()
I'm playing around with a JQuery plugin called JRumble: http://jackrugile.com/jrumble/
I setup a simple fiddle to test: http://jsfiddle.net/phillipkregg/4LP65/6/
You can see that the plugin is working fine in Chrome and Firefox, but on IE9 I am getting some errors.
Took a screenshot of the IE Developers tool to show what it is referring to:
I copied the text in the console just in case that image is hard to read:
HTML1115: X-UA-Compatible META tag ('IE=EmulateIE7') ignored because document mode is already finalized.
4
HTML1115: X-UA-Compatible META tag ('IE=EmulateIE7') ignored because document mode is already finalized.
4
HTML1115: X-UA-Compatible META tag ('IE=EmulateIE7') ignored because document mode is already finalized.
4
SEC7112: Script from https://raw.github.com/jackrugile/jRumble/master/demo/js/jquery.jrumble.1.3.min.js was blocked due to mime type mismatch
show
SCRIPT438: Object doesn't support property or method 'jrumble'
show, line 26 character 2
When I looked up issues with Object doesn't support property or method 'jrumble' , some of the solutions suggested that this can be caused by an id or class name that is the same as a JavaScript variable name. However, there are no conflicting names in my simple example and it is still not working in IE.
Just from looking at the console, it seems the issue might be a mime-type mismatch that is preventing JRumble from being seen by IE.
Is this indeed the problem? Does anyone know how to go about getting around this issue?
Thanks!
To further troubleshoot this, go to the Network tab, start capturing, then reload the page. Find the script and go to its detailed view. Check the content-type response header and see what it is.
This problem can be circumvented by serving the file from your own server with the correct headers.
I'm trying to do a mega-simple setItem and getItem using HTML5 local storage. It just doesn't seem to work though. This works:
$(document).ready(function () {
localStorage.setItem('keyA', 'valueA');
var testA = localStorage.getItem('keyA');
alert(testA);
});
It outputs an alert box saying 'valueA'. But when I comment out line 2 (which sets the item value) and refresh the page it just alerts 'null'.
Why is the value not persisting? It's like it's just not actually getting stored at all.
The browser is Firefox 6, so no problem there. Could it be something to do with calling it in the jquery document.ready? I've googled but couldn't see anything about that.
If anyone could get me over this initial hurdle I'd be most grateful, thanks!
Okay, after a lot of frustration I have the solution. Basically, I was running this locally just from the filesystem as a 'quick' proof of concept. It didn't work in Firefox nor in IE9 but it did work in Chrome.
What I ended up doing was trying this on a real domain, and that seems to have done the trick.
So the conclusion I can draw is that localStorage in Firefox (6.0.2 at least) and IE9 does not work when run on a file-system path. It does in Chrome. Firefox and IE9 require a 'proper' domain to run from, presumably because they are more strict than Chrome in the way they associate the localStorate object to a 'domain' (in Chrome it doesn't need to be a domain as such).
I hope this has helped people as it's frustrated the hell out of me! :)
Is there an easy way to find parse errors in javascript code?
Last week I was debugging a javascript problem where the first javascript function that was called gave an 'object expected' error. I later determined that this was because the browser wasn't able to parse my javascript code. I eventually solved the problem but it was a painful process that involved pouring over my code line by line, trying to find my mistake.
There must be an easier way.
Use a tool like Jslint or an alternative browser.
Until recently, IE was the only browser that did not have built in development assistance. Other browsers will a) not come to a grinding halt on the first error they encounter, and b) tell you what and where the problem in your code is.
My favorite "quick ad easy" way to test IE syntax problems is to load the page up in Opera. It parses code like IE but will give you meaningful error messages.
I'll clarify with an example:
var foo = {
prop1 : 'value',
prop2 : 'value',
prop2 : 'value', // <-- the problem
};
If I remember correctly: In IE6 and IE7 the code will break because IE demands leaving the last comma out. The parser throws a fit and the browser simply stops. It may alert some errors but the line numbers (or even filenames) will not be reliable. Firefox and Safari, however, simply ignore the comma. Opera runs the code, but will print an error on the console indicating line number (and more).
Easiest way to write JavaScript is with Firefox + Firebug. Test with IE and have Opera tell you what is breaking when it does.
What browser are you using? IE8 has great build-in feature to debug javascript, for Firefox, Firebug is great.
Checking that the values passed into functions are correct and throwing your own errors if they aren't will help you track down problems faster.
Safari 4 (which runs on both Mac OS X and Windows) comes with some development tools (including a debugger) that are very useful. If you prefer using Firefox, Firebug provides similar functionality.
JSLint can help you track down simple errors.
Steve