dojo.exists fails with IE11 - javascript

Since a few days, I have troubles with Internet Explorer 11 in conjunction with dojo toolkit 1.9.4 hosted by a Domino Server.
Source Code:
if (dojo.exists("btnUpload")) {
console.log("btnUpload exist ... do something...");
} else {
console.log("btnUpload doesn't exist...");
}
With IE11 the return value of dojo.exists() is always false!
IE11 Debugger:
However in all other browser (Mozilla Firefox, Google Chrome, Apple Safari) it works!

Using dojo.exists for this isn't very appropriate, given that btnUpload is technically just a DOM ID, and not an actual object in the global scope. if (document.getElementById('btnUpload')) would seem to be far more appropriate in this case.
When a global reference is encountered that doesn't match an actual global variable, but does match a DOM ID, browsers tend to return the DOM node, but I wouldn't recommend relying upon that.

Related

Browser component (IE) does not show values for document.getElementbyId

I am listening to a server event via a javascript function on my HTML file, which outputs the server answer in the console tab. Since I need to pass this answer to a delphi application, I made the server answer "visible" via a div container. This works fine on Firefox, but on IE the output is not shown. I have then tried to utilize the value of a textarea, which also works on Firefox but not on IE.
I really wonder why it is so hard to get a console output visible on IE?
document.getElementById('my_div_container').innerHTML = JSON.stringify(my_data_I_want_to_see, null, 4);
document.getElementById('my_textarea').value = JSON.stringify(my_data_I_want_to_see, null, 4);
The above lines show a result on Firefox, but on IE there is no output at all. How can I get my data visible on IE?
I found the root cause why IE did not show any console output. I just found out, that the addEventListener() method I was using is not supported in Internet Explorer 8 and earlier versions.
I am very sorry for any confusion.
If you are using TWebBrowser component in Delphi for displaying the webpage do note that by default it running in Internet Explorer 7 compatibility mode.
In order to avoid this you need to opt your program into browser emulation feature
How to have Delphi TWebbrowser component running in IE9 mode?
Don't forget to check MSDN documentation for proper registry value to enable emulation of most modern IE versions.

Internet Explorer equivalent to window.performance.memory?

Does anyone know if IE has an equivalent to Chrome's window.peformance.memory property?
I am trying to find a way to analyse IE's memory performance in my application.
Running my js script using a Chrome browser is no problem, because Chrome has added a proprietary memory property to window.performance (see window.performance.memory for more info).
The way I do it in Chrome is like this:
browser.driver.executeScript(function () {
return window.performance.memory; // this is the problem, IE has no memory property
}).then(function (result) {
logResults(result.jsHeapSizeLimit);
logResults(result.usedJSHeapSize);
logResults(result.totalJSHeapSize);
}
});
Internet explorer, use navigation.performance to make other types of measurements. More reference to speed.
https://developer.mozilla.org/en-US/docs/Web/API/Performance
For example: window.performance.now()
On this page you can see all the data that can be obtained with internet explorer or other browsers. You must enter with the internet explorer in the url, to see the data with the browser
https://browserleaks.com/javascript
Other option is using: CTRL+Shift+U keys

Internet explorer throwing Object doesnt support property or method with JQuery

I'm assuming this is pretty obvious but I can't work it out for myself. I'm using the Facebook javascript API to allow a user to login into a page I made. The following javascript throws the error Object doesnt support this property or method. IE is saying the first line is throwing the error. Anyone know what I'm doing wrong?
document.getElementById('auth-loginlink').addEventListener('click', function () {
FB.login(function (response) {
}, {scope: 'email,user_likes,read_stream'});
The page can be accessed on http://claritytrec.ucd.ie:9000/signup
You're running your page in Quirks -mode. There must not be any characters or blank lines before declaring document type.
Only IE >= 9 knows addEventListener(), use attachEvent() instead with older IEs. attachEvent in MSDN, you can find more information about the legacy eventhandling model of IE by following left-side links at the MSDN page.

How to get browser "Document Mode"

I am developing some kind of JavaScript library. And i cause the problem that i have some specific issues for:
Browser : IE8 / IE9 and Document Mode : IE7
I found the solution, but i don't want to use it in all situation, and want to use it just when i have the situation described above. I know that I can recognize browser by using:
return navigator.userAgent.toLowerCase().indexOf('MSIE 8') > -1;
But i recognize just browser version in such way but not the document mode, and i don't want to use my solution when I have, for example, browser mode IE8 and document mode IE 8.
Is there a way to get page document mode in IE? Thanks in advance.
You can use document.documentMode to return exactly what document mode IE is using.
Meaning that if you have your browser mode set to IE9, but your document mode to IE8 it will return document.documentMode == 8 (while the userAgent string will still show up as IE9). This is particularly useful if your JS ever includes styling changes as it is the document mode that determines how IE renders a page, not the browser mode. Compatibility mode really just changes the document mode (usually to IE7).
In the few cases I've needed to I've just used something like this to differentiate IE's:
if (document.documentMode == 7) {
doSomethingIn.IE7_only;
} else {
doSomething.everwhereElse;
}
Hope that helps some.
I don't know how to retrieve the document mode1, but it may be wise to address the problem in a more basic way. Let's say you wanted to use document.querySelector in your scripting. That would fail in IE8/document mode IE7 Standards. So an additional check for the existence of document.querySelector itself would be the solution:
return ~navigator.userAgent.toLowerCase().indexOf('MSIE 8')
&& document.querySelector; //=> IE8 and Docmode IE7 => false
1 Found a way to check for document mode: use document.documentMode. It returns an integer (so 7 for document mode IE7 standards), 5 for Quirks mode. It will be undefined for non IE browsers.

Check webkit version with javascript embedded pywebkitgtk?

Apparently the best way to check the version of webkit is
/AppleWebKit\/([\d.]+)/.exec(navigator.userAgent)
(as seen here and a few other places). What is this /AppleWebKit/, a hidden variable, a constant, a regex?
I noticed it worked fine in the browser, but would not work in an embedded pywebkitgtk, it returns null. Is there something missing in the embedded webkit?
/AppleWebKit/([\d.]+)/ is a regular expression which navigator.userAgent is checked against.
The navigator object returns information about the browser you use (name, version, etc). So I guess this does not exist in pywebkitgtk, as it's only a framework for WebKitGtk, not a browser by itself.

Categories