javascript

Does this javascript statement affects performance?

Hi guys, I'm writing a function add_event as the following shows: function add_event(o, event_type, callback, capture){ o = typeof o === "string" ? document.getElementById(o) : o; if(document.addEventListener){ add_event = function(o, event_type, callback, capture){ o = typeof o === "string" ? document.getEl...

Problem with background color on li tag

I am setting background color of an li element by the code below : $('#li123').animate({ backgroundColor: color}, 'slow'); It works fine but the color spans whole length of li. What do I do if I want it to span the text contained in the li only. ...

web page requires a reload before displaying javascript content... in all browsers other than MSIE.

Hi, in all browsers I've trid other than ms internet explorer, I need to reload before my slider menu is visable.. could anyone shed some light!? http://www.musical-transformations.com/gallery/index.html Thanks, ...

asp net javascript Cache clear

I have a website that i did some time ago now they request some new features and i did some changes in some javascript files, but when i publish the clients that use the IE have problems with cache so in they browser they have old version of javascript. How can i clear the client cache so when they visit website they use latest javascrip...

Most effective way to auto detect/select language in a website?

Hello, I need to implement an autodetect feature for a simple, plain html website I am working on. It has two languages and the client wants it to automatically select the language. This could be done either via the browser's language or geolocalization, both options are good. Can someone point me to a good script or solution to do th...

Using charts in web application (negative value in bar chart)

I want to use bar chart in web application. I have searched many libraries including google code, and many but many do not support negative values for bar charts. ...

Interactive javascript logical expression builder?

I'm looking for some sort of a generic logical expression builder, like the SmartClient FilterBuilder but lighter - SmartClient weighs 500kb or ~160kb GZipped which is unacceptable for our application. Our server-side is Java/Spring-MVC, if it matters. Any suggestions? ...

How can I convert a php timestamp to the same format as new Date() in javaScript?

I have a time stamp I created with PHP that I would like to convert to the same format as new Date() in javaScript. Here's my code: $current_timestamp = time(); //This returns a value such as 1268214657 I need to create a string using that timestamp that looks like this: Fri Mar 12 2010 01:50:33 GMT-0800 (Pacific Standard Time). ...

onMouseOver(SomeInt, SomeString) not working

I'm creating the following div using javascript, task_id is an int and person_name is a string, why is my alert not working! when i send 2 integers, the alert works fine, when i send 2 strings the alert still doesn't work, what am i doing wrong? '<div " onMouseOver="Drag(' + task_id + ',' + person_name +');"</div>' ..... function Drag...

How to check if object literal is not in page?

I'm trying to check for if my object literal is not in my page. var today = { okay : true } If this snippet is not in my page I want to check for null or undefined but it kills silently... if (today.okay == null) if (today.okay == undefined) What to do? ...

google caja how to use

let say i have a page , and i want to allow 3rd party to embed small application/iframe into my page. in order to use caja on my page to secure the 3rd party small app/iframe. do i need to put any extra javascript/serverside code in order to use caja? fetching of the 3rd party small application is done through proxy or direct iframe? ...

jQuery get attribute...

Hi guys, I'm trying to get the source attribute of all images withing a specific div but somehow it keeps telling me that the function .attr() doesn't exist... That's the function. Firebug also tells me that "this" is an image element. I'm using jQuery v1.3.2 $('#products LI DIV IMG').each(function() { var image = this; alert(ima...

Dynamically creating a TreeViewin HTML with indent lines in ASP.NET

Hi, i'm quite new to HTML, and am trying to create a professional looking TreeView. I can not use the in built TreeView in ASP.NET as i need to point the target of the selection to another frame (I have tried, and this doesn't seem possible). My TreeView is built up as follows: Folder1 ChildOne ChildTwo ChildThree Folder2 ...

Implement delay in javascript without killing the processor

Hi. I want to return the function when a certain time has passed. In my function below the return thing didn't work(the alert was triggered). The thing is that in my handleRequestStateChange I initialize myArray. function() { xmlHttp.open("POST", "xxx", true); xmlHttp.setRequestHeader("Content-Type", "application/x-www-form-u...

Escaping characters in Objective C on iPhone

I'm trying to pass the following string: NSString* jsString = [NSString stringWithFormat:@"myFunc(\"%@\");", myParameter]; from Objective C to JavaScript using the stringByEvaluatingJavaScriptFromString, where myParameter is a string value. How can I ensure that the myParameter string doesn't contain any JS-unsafe characters without b...

Preventing code replication in javascript by combining these functions

So I have two jquery functions that bassically do the same, but on 2 seperate containers. Is there a way to combine these two functions. $('#autobid-list .auction-button').click( function(){ if($(this).attr('summary') == 'autobid-button'){ $(this).parents('li').addClass('none'); }else if($(this).attr('sum...

jquery validation

hi I have some problem to execute the following jquery validation program email: { required: true, email: true, remote: "emails.php" }, ......... in jquery validation $.ajax($.extend(true, { url: param, mode: "abort", port: "validate" + element.name, dataType: "json", data: "email="+data, The above co...

javascript removeChild(this) from input[type="submit"] onclick breaks future use of form.submit() under firefox

I have come across some strange behaviour, and I'm assuming a bug in firefox, when removing a input submit element from the DOM from within the click event. The following code reproduces the issue: <form name="test_form"> <input type="submit" value="remove me" onclick="this.parentNode.removeChild(this);" /> <input type="submit" value="...

How to redirect to root page in Rails in jQuery?

I'm now redirecting to main page in my Rails application using redirect_to root_path I want to do the same in jQuery. i.e. window.location.replace("???"); How to do that? ...

how to display data in binary tree in asp.net

i am working on Multi Level Products.i need to display data in the form of binary tree how to go for it. is there any control to display it or is there any other way ...