javascript

When is it OK to use Javascript and when not?

Is it good practice not to use much javascript/jquery? Should we avoid it as much as possible (for good accessibility)? When is it OK to use JavaScript and when is it not in web design and development? In what scenarios and with what conditions? Update: I'm asking regarding public websites. ...

setInterval pauses in Android Browser / Mobile Safari when screen times out

I've built a simple JavaScript-based timer for a mobile webapp; for the sake of example: var a = 0; setInterval(function() { console.log('a', a); a++; }, 1000); This runs just fine in both Mobile Safari and Android Browser. It will log to console every second and increment the value of a accordingly. (Okay, Android Browser doe...

ExtJS - Save State of treePanel.

TLDR I want my treepanel from EXTJS to remember its previous settings. ExtJS-3.2.1 I have seen this done before for ExtJS-2.x.x :See here on the extjs forums. But as seen as they are pretty much lifeless, with threads on there asking this question or similar with no reply for up to 6months. I thought I would bring it here. I need to ...

Running a javascript inside the head tag in Selenium RC

I want to run a javascript snippet inside the <head> tag. Is that possible to do that in Selenium RC+Java? I understood that if I use getEval or runScript that will insert the code inside the HTML body. Any Ideas? Thanks ...

Updating Silverlight with data. JSON or WCF?

We will be using custom Silverlight 4.0 controls on our ASP.NET MVC web page to display data from our database and was wondering what the most efficient method was? We will be having returned values of up to 100k records (of 2 properties per record). We have a test that uses the HTML Bridge from Javascript to Silverlight. First we perfo...

How to add <li> using javascript?

I want to add one more li at last but using JavaScript/jQuery for example i want to add this li at last <li><a href="#header" >Back to top</a></li> <ul id="nav"> <li><a href="#nowhere" >Lorem</a></li> <li><a href="#nowhere" >Aliquam</a></li> <li><a href="#nowhere" >Morbi</a></li> <li><a href="#nowhere" >Praesent</a></li...

Javascript Source to textarea value

I am creating some JSON on the fly, serializing it and saving it to the DB. To run it, i create a script element, and load it that way. Is there a way to load the script source to a textarea? ...

javascript in an address bar

Hi, I have a small problem. When im executing a javascript in an address bar and the function that i'm calling there returns a value. The page moves to a new page. To prevent this, i use a void(0) at the end. But once this is done, how can i capture the returned value of the function. For eg: javascript:function f(){return 'success'} ...

How can I append some results to a jQuery autocomplete drop-down box?

I'm using http://docs.jquery.com/Plugins/Autocomplete I'd like to add two results to the end to always appear. How would I do this? ...

prevent other event keydown on change

Hi, on my textbox i have 2 events onchange and keydown(for enter) now i did validation on onchange event if any validation fail then i raise alert but when i press press enter button if validation failed then i dont want to execute keydown event any suggestion Thanks, Nik ...

The Stackoverflow alert box, How is it done?

Possible Duplicate: jQuery alert plugin that produces alerts like Twitter/StackOverflow? Question says it all. Can someone point me to an example of how they do the alerts at the top when a new message arrives or someone posts to my answers or I just have a notification.. Thanks. P.s. I would love a JQUERY solution, but can...

how replace a character in a string in javascript

i have a string : var s="here_we_go"; how can i replace all occurrence of '_' by '$' so the string will become: s="here$we$go"; ...

Jquery forms plugin problem

I have the following: $(document).ready(function(){ // bind 'myForm' and provide a simple callback function $('#form').ajaxForm(function() { alert("Works!!!"); }); }); The problem is that when I dynamically add the form to the HTML the script is not working. If the form is the...

javascript library to display / animate 3d objects?

Hi, I have saw some time ago library where you can import your 3d objects and it will draw those out. You could also animate the objects. The webpage itself was back and there were rotating gear at the corner... Can anyone recall the name of the library? Also you can mention if you know some other neat js libraries. Thanks! ...

Page.ClientScript Register a pair of javascript code

How can I register a javascript code a page? I want to put th javascript function to the aspx.page; I thing it might be like that; string strJS= "<script language = javascript> (function(images, elements) { var fetchImages = function() { if(images.length > 0) { var numImages =...

Cross domain ajax back button

Hi. I was searching for a way to implement back button in an ajax application (nothing unusual) as there are plenty of articles that cover this topic. But... But of course there are many restrictions. So my problem that is still not solved is regarding back button in IE6,7. More specifically it is regarding back button when you displa...

set/unset checkboxes in JSF

Hello, i've got one problem with checkboxes in JSF. I want them to behave dependently on each other, e.g., when i check a box which belongs to some object that has children then all checkboxes that belong to these children components must be checked either. And also when i uncheck one of child's checkbox the parent should be unchecked to...

How to scroll to specific position in BlackBerry web browser?

How to scroll down / up to the specific position by using JavaScript in BlackBerry web browser? Are properties like scrollOffset, scrollTop, scrollLeft etc. are supported? If not what code can be used? ...

ajax strange error with sending multiple parameter

hi everyone, please check with me where is the error in this ajax code to send 2 parameters: var xhr = getXhr(); // On défini ce qu'on va faire quand on aura la réponse xhr.onreadystatechange = function(){ // On ne fait quelque chose que si on a tout reçu et que le serveur est ok if(xhr.readyState == 4 && xhr.status == 200) ...

Javascript / jQuery Exec turns up Null

How do I skip over this next line if it turns out to be null? Currently, it (sometimes) "breaks" and prevents the script from continuing. var title = (/(.*?)<\/title>/m).exec(response)[1]; $.get(url, function(response){ var title = (/<title>(.*?)<\/title>/m).exec(response)[1]; if (title == null || title == undefined){ r...