javascript

Best Online Code Editor (with a Textarea)

Really surprised, Googling for a decent online code editor provided little results. Just wondering if anyone has any recommendations for an online code editor which is: Good looking Ideally jQuery Uses a <textarea> Highlighting for CSS Has line numbers So far the best I can find is: http://codepress.sourceforge.net/ Thanks in advan...

Connecting to a socket via JavaScript (without flash)

I have a browser based app that needs to communicate with another service running on the client machine via a socket connection from the browser using JavaScript. I need to post and parse XML back and forth on the socket. I am unable to go down the flash path as the cross domain security is a barrier, ie the service running on the sock...

Rails: Form confirm message with data from the submitted form

Trying to make a custom :confirm message for a rails form that returns data from the submitted form--not just a static string. <% form_for @foo do |f| -%> <% f.text_field :number_of_bars -%> <% f.submit :confirm => Are you really sure you want to use ##number_of_bars## bars? -%> The idea is if the user puts in the number 3 in the numb...

How can I tell when a web page resource is cached?

Is there a way in JavaScript for me to tell whether a resource is already in the browser cache? We're instrumenting a fraction of our client-side page views so that we can get better data on how quickly pages are loading for our users. The first time users arrive on our site, a number of resources (JS, CSS, images) are cached by the bro...

Calling javascript function in asp.net

Ok so this is a snippet of my aspx file, I am trying to call a "hello world" function from the 'test.js' file. This is obviously not working, could someone please recommend me a good way of doing it? <asp:ScriptManager ID="ScriptManager1" runat="server"> <Scripts> <asp:ScriptReference Path="\App_JavaScript\test.js" /> </...

How do I rotate an image in Javascript or CSS

I am creating a simple game. I want to use jQUERY to rotate the joints making it move. I am using .animate ( http://api.jquery.com/animate/ ) to animate CSS properties but if it is also possible to use Javscript, I can make my own custom code. More TO-THE-POINT How do I rotate images in CSS or Javascript? I prefer CSS but Javascript i...

Extjs & explorer & file upload

We have got an extjs 3.1.1 form with file upload field (http://www.extjs.com/deploy/dev/examples/form/file-upload.html from here, the latest). After successful submission the reply is {"success":true} with application/json content type. We use Zend Framework as backend, json is generated with json helper. This works like a charm in fire...

What information about a DOM element would allow JavaScript to identify it (somewhat) uniquely? (e.g. when it doesn't have `id`)

Here's what I'm trying to do: I have a bookmarklet that is looking for elements in the current page (which can be any site) and dispatch a click event on the ones that match. I have that part working. In some cases though, nothing matches automatically and I want to be able to show (by hovering it) what element should be activated and t...

Dropdown Option set innerHTML sets value as well

I just found out that in FF, if you are dynamically creating an OPTION DOM element inside a SELECT element and just set its innerHTML, it sets both the innerHTML i.e. the displayed text as well as the value of the OPTION. var opt = document.createElement('OPTION'); opt.innerHTML = 'Opt'; this set the "value" attribute as well of the e...

pass post data with window.location.href

When using window.location.href, I'd like to pass POST data to the new page I'm opening. is this possible using JavaScript and jQuery? ...

SEO/PHP: How to Convert Form-Submit URL (Get-Method) without Javascript SEO-Friendly?

hello, i have this code <form action="index.php" method="get" class="search-form"><input type="text" size="35" name="search" class="searchBox" value="" /><input type="submit" value="Start Searching!" /></form> and actually i convert the url with javascript <script type="text/javascript"> $(document).ready(function() { $('.search...

Passing JSON to Python script via AJAX

What's the ideal way to pass a large JSON data object from Javascript through AJAX to a Python script? ...

Cache HTML Content by storing inside javascript variable in external js file?

I have a web application where the masterPage/template contains some static HTML that never changes but is sent with every request. (a lot of this HTML are hidden elements that are shown after a user does something) I'm wondering if there is some way of caching it? I was considering putting the HTML inside a javascript variable and doi...

differentiate between a scroll caused by .scrollLeft and a user trying to scroll in an HTML page

I have a scrollbar that has to follow some timeline. It is being constantly scrolled with .scrollLeft using setInterval. I still want the user to be able to naturally take control and just drag the scrollbar away. If I can detect the user did that, I would just turn off the setInterval timer and leave the control to the user until he e...

Why use <canvas> instead of plain old Javascript?

Some of the HTML5 canvas demos are very impressive, but I'm a bit confused. What can the canvas element do that regular old JS/jQuery and CSS3/HTML5 can't? Are there performance benefits? ...

submit multiple forms to same page

I have three forms on a page. They each have multiple inputs including files. I would like so that when I submit the last form, the inputs for all three forms are sent to the POST data for the action location. I can jQuery if necessary. ...

jQuery events and .load()

Hi All Never ran into this problem with jQuery before. I have the following: $(document).ready(function() { $('#browser_cat a').click( function() { $('#browser_cat').hide(); $('#browser_cat').load('/api/browser/catchildren/'+$(this).attr('id')); $('#browser_cat').fadeIn(); return(false); }) }); ...

simple "this" issue with JavaScript fundamentals

var name = 'Mike'; var person = { name: 'John', welcome: function(){ var name = 'Mary'; return 'Hi ' + this.name; } } //person.welcome(); // output is // Hi John // I was expecting output to be // Hi Mary person.welcome.call(); // output is // Hi Mike // In this case since no argument is passed to call so this is window ...

scrollTop in defferent browers.

shortcut.add("up",function() { alert( document.body.scrollTop) if (document.documentElement&& typeof document.documentElement.scrollTop=='number'){ document.documentElement.scrollTop-=100 } else if (document.body) { document.body.scrollTop-=100 ...

Prevent drupal from loading other module's javascript

I have a drupal page that I'm using in a way that's very different from all the other pages of the site. I have a module that loads a set of specialized js on this page. I'm finding that my JS does not work well with the js from other modules or perhaps drupal core. How can I prevent the other modules from doing drupal_add_js on that s...