Get table row object inside javascript function - DHTMLX - javascript

We are doing cross browser compatibility for an application which was built over 8 years ago. The app works only in IE. Now we are making it work in Chrome too. The application had used 1.5 version of DHTMLX. Now we have replaced it to version 3.5. After upgradation to 3.5, we are having some issues. At some places, we are getting NULL values in Chrome when debugged in the console.
For example, we have this below function. On click of a DHTMLX grid checkbox, this function is called.
var glbGroupId=null;
function setRowCellVals(){
if(arguments[0]!=null){
radioFlag = true;
src=$(arguments[0]);
if(!glbCheckAction){
if(src.childNodes[0].childNodes[0].checked){
src.childNodes[0].childNodes[0].checked=false;
}else{
src.childNodes[0].childNodes[0].checked=true;
}
}
glbCheckAction = false;
glbGroupId=src.childNodes[0].childNodes[0].value;
document.manageKpiGroupForm.parent_GId.value = src.id;
document.manageKpiGroupForm.parent_Gname.value = src.childNodes[1].innerHTML;
document.manageKpiGroupForm.parent_mId.value = $F('moduleCmb');
document.manageKpiGroupForm.parent_mName.value = src.childNodes[3].innerHTML;
document.manageKpiGroupForm.parent_gDesc.value = src.childNodes[4].innerHTML;
moduleRowId=arguments[0];
return true;
}
}
In Chrome, the src is being rendered as NULL. We checked the same function in IE, in another copy which has the older version of DHTMLX, the src value comes as [object DispHTMLTableRow] in the IE console. Any idea how to resolve this?
Thanks.

Unfortunately, the reason of the issue cannot be found with the provided code.
Please provide with a more detailed sample or with the link to the demo, where the problem can be reconstructed.

Related

Disable JavaScript Alerts GeckoFX C#

I'm trying to disable JavaScript alert in GeckoFX-33 + xulrunner 33 ( winforms c# ) but I can't find a solution. I check the example codes, source code but I just can't find something that blocks the alert out. I searched in about:config as well without success.
Anybody knows where I could find a reference at last ?
In prior versions, you could do
webBrowser.JavascriptError += (sender, error) => {
// do something
}
However according to issue 7 on geckofx 33, there's some work that needs to be done to support the new debugging interface:
the geckofx service jsdIDebuggerService was removed from firefox 33. the JavascriptError event implementation used this service. So the JavascriptError event handler needs to be reimplemented using firefox new debugging interface.
geckoWebBrowser1.JavascriptError += (sender, error) =>
{
GeckoWebBrowser browser = geckoWebBrowser1;
string text = "window.alert = function(){};";
using (AutoJSContext context = new AutoJSContext(browser.Window.JSContext))
{
string result;
//toolStripLabel1.Text = "was is loaded?";
context.EvaluateScript(text, (nsISupports)browser.Window.DomWindow, out result);
}
};
Here is the final code for Gecko 29.

html().split() not working in Chrome/IE but working perfectly in Firefox

I have a line in my jsp that is not working in Chrome and IE but works in Firefox:
var readInnerHtml = $(rowElement).html().split('<input class="')[1];
Its becomes undefined when my application runs in Chrome or IE. Can anyone help in this?
My actual function is:
function rowAdded(rowElement) {
$(rowElement).find("input").not('input[type=hidden]').not('input[type=checkbox]').val('');
$(rowElement).find('input[type=hidden]').val(0);
var ele = $(rowElement).find('input[type=checkbox]');
var indexString = $(rowElement).html().split(']')[0];
var readInnerHtml = $(rowElement).html().split('<input class="')[1];
var checkForOutputDef = readInnerHtml.split('"')[0];
............
}
here i observed one thing that split('....') working in both browsers but split('....').[1] working in only firefox but not in chrome can any one describe me what i must do now??
Reposting my comment for formatting
Do not try to parse HTML. Look in the console for what Chrome actually uses - for example the quotes may be single instead of double or the tag uppercase. Use className = ele.attr('class'); or .prop("class")
function rowAdded(rowElement) {
$(rowElement).find("input").not('input[type=hidden], input[type=checkbox]').val('');
$(rowElement).find('input[type=hidden]').val(0);
var checkForOutputDef = $(rowElement).find('input[type=checkbox]').attr("class");
}

files.length is undefined in Internet Explorer

I'm using
$(upload_button).bind('change', function(event)
{
var files = this.files;
alert(typeof(files));
if(typeof(files)!='undefined')
{
}
});
in my code with jQuery which is working fine in Firefox and Chrome but not in IE8(i.e., IE returns undefined for files.length, whereas others returns the value). So do anybody know how to resolve this?
That's because Internet Explorer, even IE9 does not support HTML5 File API and therefore it returns undefined value for files property.
From jQuery API.
change event will not work with button as I am assuming upload_button is button.

Javascript issue in IE9 with Windows 7 Professional and not in Windows 7 Enterprise

Is it possible to get a javascript related error only in IE9 with Windows 7 Professional and not in IE9 with Windows Enterprise?
Can there be any difference in the way IE9 behaves with respect to javascript between a 32-bit Windows 7 and a 64-bit Windows 7?
Please help me with this. The full javascript function is below.
function foo() {
var isChecked = false;
var checkBoxField = "MyCheckBox1";
for(j=0;j<document.forms[0].elements.length;j++) {
if(document.forms[0].elements[j].name.search(checkBoxField) == 0) {
if (document.forms[0].elements[j].checked == true) {
isChecked = true;
}
}
}
alert(isChecked);
}
The isChecked variable has to be true when the checkBoxField is checked. It is true in IE9-Windows 7 Enterprise Edition (Not sure about 32-bit or 64-bit) and it is false in IE9-Windows 7 Professional Edition (32-bit)
Apologies. After looking at the IE settings in the exact machine where the issue occurs, it is clear that it is due to caching. The setting Preserve Favorites website data preserves the old js file and is not downloading the updated version (even if we try to clear cookies, history, temporary files etc). Once that setting is unchecked - history, cache cleared everything started working.
Cheers,
Apologies. After looking at the IE settings in the exact machine where the issue occurs, it is clear that it is due to caching. The setting Preserve Favorites website data preserves the old js file and is not downloading the updated version (even if we try to clear cookies, history, temporary files etc). Once that setting is unchecked - history, cache cleared everything started working
There shouldn't be any difference in different windows version, since most time you'll be using 32 bit ie. But you never know what kinda of bug is in ie javascript
what you can try is is use jquery
you code looks like
function foo() {
var isChecked = $("name='MyCheckBox1':first").attr('checked');
alert(isChecked);
}
set your checkbox id to MyCheckBox1 and it further simplifies
function foo() {
var isChecked = $("#MyCheckBox1").attr('checked');
alert(isChecked);
}
Not sure if it'll help you, but that's my 20 cent.

Cannot access document's title element with jQuery (IE 8)

I'm seeing this issue in Internet Explorer 8, but not in Safari or Firefox. So far, I have not tested in other IE versions.
I am developing my own jQuery plugin and, for this question, I've stripped it down to the two relevant lines.
In IE 8, using the code below, $('title').text() does not do anything. docTitle is blank because title is blank, as if the jQuery selector for <title>, $('title') is not working. (Again, AFAIK, this is just in IE 8)
(function ($) {
$.fn.myPlugin = function (options) {
var title = $('title').text(),
docTitle = escape(title);
};
})(jQuery);
http://jsfiddle.net/sparky672/YMBQ2/
However, using the plain JavaScript code below, document.title is working fine in everything including IE 8...
(function ($) {
$.fn.myPlugin = function (options) {
var docTitle = escape(document.title);
};
})(jQuery);
EDIT:
It does not matter that this code is inside a plugin.
Same result in IE 8 with this...
$(document).ready(function () {
var title = $('title').text();
alert(title);
});
Just to clarify, I am not insisting on using this. In fact, I fixed my plugin by simply using document.title instead. If it wasn't clear initially, I'm just asking why this does not work in IE 8.
Can anyone explain why, or what stupid mistake I may have made here?
EDIT 2:
Here are some jQuery Bug reports on this issue
http://bugs.jquery.com/ticket/7025
http://bugs.jquery.com/ticket/5881
http://bugs.jquery.com/ticket/2755
And dozens of others reporting the same thing. The official response is to state, "document.title is the only reliable cross-browser way and should be used instead" and the Ticket is closed. So there you go.
I guess jQuery iterates over all TextNodes and concatenates its nodeValue. IE stores this value differently than other browsers.
var title = document.getElementsByTagName('title')[ 0 ];
title.firstChild // This would be the Text-Object with the characterdata of the title
// Firefox: [object Text]
// IE: null
This should be the reason you cannot get the textContent with jQuery.text(). title.text seems to be cross browser comp. I only tested it in IE 7 and Firefox 3.6 but you can check the other browser if you like. But why not using document.title?
try using $('title').html() which should work in all browsers

Categories

Resources