Bitwise AND operator
To alternate the table background color:
rows [i].className = ((rows [i].index & 1) == 1) ? "alt" : "";
To alternate the table background color:
rows [i].className = ((rows [i].index & 1) == 1) ? "alt" : "";
Posted by
Ginger
at
9:59 AM
0
comments
Labels: Javascript, operator
- Example 1
var regex = /<title[^>]*>([\s\S]*?)<\/title>/i;
while(match = regex.exec(httpResp)){
if ('Login Page' == match[1]) {
...
html += ' <a href="javascript:showManyToMany (groupsForUser, \'' +
rowData.name.replace(/\'/g, "\\'").replace(/\"/g, "&.quot;") + '\');">Edit</a>';
Posted by
Ginger
at
5:18 PM
0
comments
Labels: Javascript, regex
DWR has a global handler textHtmlHandler for this purpose. When a DWR request receives a response that isn't Javascript. It indicates a server session has timed out, and we can redirect user to logon screen in this handler. So any DWR call doesn't need to worry about session timeout.
dwr.engine.setTextHtmlHandler(function() {
document.location.reload();
});
load: function(type, data, evt) {
sessionTimeoutCheck(data, evt);
...
}
dwr.engine.setErrorHandler(handler);
Remote.method(params, {
callback:function(data) { ... },
errorHandler:function(errorString, exception) { ... }
});
dwr.engine.beginBatch();
Remote.method(params, function(data) { ... });
// Other remote calls
dwr.engine.endBatch({
errorHandler:function(errorString, exception) { ... }
});
Posted by
Ginger
at
4:13 PM
0
comments
Labels: ajax
In JavaScript, undefined means a variable has been declared but has not yet been assigned a value, such as:
var TestVar;
alert(TestVar); //shows undefined
alert(typeof TestVar); //shows undefined
var TestVar = null;
alert(TestVar); //shows null
alert(typeof TestVar); //shows object
typeof(SomeObject) == 'undefined'
Posted by
Ginger
at
10:56 AM
0
comments
Labels: Javascript, undefined