javascript

Which methods do you prefer to test the speed of your Javascript, and why?

I was simply wondering what methods folks are using to test their javascript's execution speed and look out for performance bottlenecks, whether they simply be code snippets or services. I'd also like to know why you would advocate this method. Flexibility? Simplicity? Or perhaps there is a single, right way. Whatever it is, I'm looking...

How can I simulate a click on a jQuery UI radio button?

I have some radio buttons <div id="typeRadios"> <input id="character_chartype_a" name="character[chartype]" type="radio" value="A" /><label for="character_chartype_a">A</label> <input id="character_chartype_a" name="character[chartype]" type="radio" value="B" /><label for="character_chartype_b">B</label> </div> that I turn int...

Production usage of compiling Ruby Red to javascript

There has been a lot of discussion over this ability (such as in this SO question, or this github thread) to compile ruby to Javascript. The original version of Red is quite old, but Julius Eckert seems to have picked it up and made it far more usable (and even presented it) After seeing the community backing up compiling other language...

how to split <p><span>Hello</span></p> to <span>Hello</span> using javascript

how to split <p><span>Hello</span></p> to <span>Hello</span> using javascript var text = "<p><span>Hello</span></p>"; remember:I don't know what contain <p>, I don't know if <p> has any attribute or not I found the answer ! var patt=/^<p.*?>(.*)<\/p>$/i; var result=patt.exec(text); alert(result[1]); thank's ring0 & w3schools http...

In Firebug, $ == jQuery returns false, only sometimes

Okay, I have this weird problem in Firefox. I type in Firebug's console $ == jQuery Sometime it displays true, and sometimes false. The file is just an empty HTML document with one script tag including jQuery. I refresh the page, click "Run" in the console, and again, occasionally it returns true, occasionally false. On the occasi...

How to keep the header static, always on top while scrolling?

How would I go about keeping my header from scrolling with the rest of the page? I thought about utilizing frame-sets and iframes, just wondering if there is a easier and more user friendly way, what would be the best-practice for doing this? ...

How to select the <tr> which holds the <a> andchange the color

Hi All, I have a table structure: <table style="width: 100%;"> <tr> <td> <a href="#" class="xx">one</a> </td> <td>Two</td> <td>Three</td> </tr> <tr> <td> <a href="#" class="xx">Four</a>...

Is a <head> element always available in the DOM, even if absent in the HTML markup?

Every browser I've observed creates a <head> element that's accessible in the DOM even if there are no explicit <head></head> tags in the document's markup. However, Google Analytics uses the following code for dynamic script insertion: (function() { var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async...

get the text content from a contenteditable div through javascript

I want retrieve the text content from a contentEditable div through javascript. What are the options of doing this? I've tried innerHTML but it doesn't work. ...

Javascript wrapper that gives us Rubyish Javascript?

Are there any frameworks/wrapper out there that gives us rubyish javascript? Instead of the usual for() {} loop gives us the object.each {} loop like in Ruby? Since javascript could be used in web browsers I do want to use it for the server side too, but I do like ruby syntax far more. ...

Any chance that ruby could be used on client side?

For scripting on web browsers, the only option now is using javascript. I wonder if Ruby ever could make it to the web browsers? It's highly unlikely cause MS doesn't have any reasons for letting Ruby to become first class citizen, wouldn't that be bad for their current platform? I don't know how Apple sees it. If Ruby can't be first ...

Showing one text box value in another text box while user type the value to the text box

Hi Guys, Is there a way to get the value from one text box and add it to another using jQuery dynamically when user is typing the value to the text box? can someone please explain the method if there is any such thing? regrds, Rangana ...

AJAX: How to use TWO xmlHttpRequest in parallel in ONE function?

How should I do this? function(id,id2){ if (window.XMLHttpRequest) { // code for IE7+, Firefox, Chrome, Opera, Safari xmlhttp=new XMLHttpRequest(); } else { // code for IE6, IE5 xmlhttp=new ActiveXObject("Microsoft.XMLHTTP"); } First Request: xmlhttp.open("GET", "http://example.com/ajax.php?id="+i...

How to fix the back button when user clicks a link from ajax-populated infinite scroll search results?

I have infinite-scrolling pagination on a search result page using ajax. How can I make it so that when a user clicks a link off-site and returns via the back button, the results are scrolled into the ajax-loaded portion of the page where they left? ...

How to share contents of a web page with social Networks and bookmarking them in on-line bookmark services??

Hi, I'm Looking for a free(or Open Source) Sharing Script to put it in my content pages(I do ASP.net). I want to allow my visitors to share contents(ex: articles) in social networks like Facebook or on-line bookmark services like google bookmarks. what's the best way to do that? i found JQUERY SHARING(you can see demo here) Plugin from t...

Problem posting to the user's wall using Graph Api.

Hi, I am trying to post to the wall. It does not work when i add arguments like link, name and caption. function graphStreamPublish(){ var body = 'This is a test feed'; var url = 'http://www.my-site.com'; var heading = 'Check out the link.'; var caption = 'I am trying to ...

How do I use closures to access twitters @Anywhere javascript api?

I want to do something that in a classical object oriented language like Java, C# etc. is very easy to do. I simply want to access a property of an instantiated object. The object is globally scoped in the browser's window object, and provided by the twitter @anywhere API. For my code examples, assume you have already logged the user ...

How do I create an array of Points?

How to create point object containing x,y and creating its array? so that i can loop over those points, add/remove points dynamically. ...

Json(/hash) to ruby object?

In Javascript you can access json as objects. person = { name: { first: "Peter", last: "Parker" } } person.name.first In ruby I have to use it like this: person[:name][:first] Is it possible to access json (and hash) as an object just like in javascript? ...

Websocket (javascript) vs Silverlight (ruby, python, javascript, c# etc)?

Just for clarification, is the question: websocket vs silverlight? Cause websocket is based on HTML enabling the web browser and web client to talk with each other live. Does this mean that developers cannot use Ruby/Python in client side, but only Javascript? If I use Silverlight, then it seems possibly for developers to use Ruby/Pyth...