javascript

How can I pair handlers for mouse event in CSS

According to XHTML 1.0 transitional events handlers should be paired. I.e the event handler onmouseout should be paired with onblur. How can I do that? ...

jQuery background position animation clipping

I have three PNG's of bubbles that I'm using for a background animation with jQuery and also have the jQuery jPlayer running on the splash page. For some reason a portion of it clips. Has anyone else run into this problem? I am a bit of a jQuery beginner and I also can't seem to get the images to repeat horizontally 100%. Also the animat...

How (or more appropriately: Why) does JSON.Stringify change the Date() value?

See example of the issue here: http://www.jsfiddle.net/s2uYE/ Notice the second new Date() is 1hr behind the first new Date() even though they are initiated at the same time. This caused me so end of confusion in a recent project and I would just like to know why this happens and if this is a bug in how browsers handle dates when strin...

Load default value for a comboBox extjs

how can i load a default value from my json store (remote) into a combobox , i've tried load the store before render the combo , and use setValue() i want my combo to display the first result in the store plz tell me the right way to do this and thanx ...

Jquery / Javascript Dynamically load CSS file (after runtime), replacing other css file?

I've been reading up on how I can dynamically load a css file using jquery at the page's runtime, but haven't been able to find anything on this... what I am wondering if it is possible to basically re-load a css file to reflect changes from the server side.. The reason for this is that I am making an app that offers a number of differe...

Loading offsite content with AJAX

I'm building a PHP page that will load some off site content into a DIV. There are other static elements on the page also. The problem I'm having is that the page takes too long to load because PHP loads the off site content before displaying the page. I am considering loading the off site content in the DIV via AJAX. I'm assuming the r...

Looping for Deep Nested Array

Hi, I am here to ask a nested array question. I have a file say, "content.json" which has javascript variables and json as their values in json there are objects as value and objects as value of each object. I mean there is deep chain to overcome to reach the final value and it is not already decided how many elements at the root are an...

A bunch of little closures vs one big one

I have a Google Map, and I am adding event listeners to different things. For instance, I have a Point object, and for this object, I have been adding events as thus: google.maps.event.addListener(this.marker, 'click', (function(point) { return function(event) { alert(point.index); }})(this)); I have a lot of these ev...

jQuery .load() callback function fires multiple times

the first time the code is executed it correctly produces: load complete but the 2nd time it produces: load complete load complete the 3nd time it produces: load complete load complete load complete etc... so the 20th time the load function completes the call back function gets fired 20 times. $('#image-tag').load(function () { ...

Listen to all javascript events

Is it possible to listen to all javascript events? I'm trying to guess if there's an event triggered after the DOM is modified by an AJAX request. ...

Is it possible to auto refresh a DIV on MySQL change in: PHP or Java Script or AJAX

I have a facebook like system, I want the DIV containing the messages to automatically update when a new message is posted. Is this possible? If so, how would i go about doing this? <?php include('config.php'); ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"&gt; <html> <head> ...

How do I prevent people from hacking my applet?

Manipulating an applet is as easy as entering javascript:document.getElementsByTagName("applet")[0].publicMethod(); into the address bar. How can I protect my applet from such manipulation? ...

Filter jcarousel content

Hello! I don't know if it's a bug or not, but here's my problem: I filter the jcarousel content using jquery. Everything goes ok until i start to use the next/prev buttons. On the default stage of filtering, buttons are working ok, but after i start to filter the content (images) the jcarousel start to work all crazy. For example, if i ...

Applying javascript to website with appcelerator titanium

I'm try to use accelerator Titanium to add native commands to a webapp. http://appcelerator.com/ I'm changing the window location to an external website like this: window.location = http://site.com; I want to bind events on that website. $('a').click(function () { alert('clicked'); }); The site has jquery loaded, the index.html...

how to cut out the photo and display on web in ruby script?

Hi there, the photo display sript is below: <% if user.image %> <%= image_tag user.image.url('100x20') %> <% end %> How can I only showing the right side of the photo by 20 x 20 on the web. it mean cut off the 80% on the left show only 20% of the whole picture. Many thanks! ...

Auto incrementing ID's of cloned sections not incrementing

Hi guys, ok so I have these 3 fields that I am cloning, using jQuery, but for some reason the ID's are not incrementing as they should, they all end up with the same ID's, here is the jQuery code: $(document).ready(function() { $('#btnAdd').click(function() { var num = $('.clonedSection').length; var newNum = ne...

What is the correct way to encode an inline javascript object, in order to protect it from XSS?

It turns out the following which looks like valid javascript, is not: <html> <body> <script> json = {test: "</script><script>alert('hello');</script>"}; </script> </body> </html> The same text, when returned JSON via an ajax api works just as expected. However when rendered in-line results in a basic XSS issues. Given an arbitrar...

JavaScript images

How do I display the same image on the same page multiple times? <head> <Script language="javascript"> function xdf(){ for (i=0;i<10;i++) { document.write('<b>hello world</b><br>'); } } </script> </head> this code displays "hello world" 10 times. i would like the same thing but with certain image instead of "hello word"... ...

How to use AJAX Post to invoke ASP.NET MVC Controller action and return new View?

I am working a site in ASP.NET MVC where the user is presented with a calendar, and clicking on a particular calendar date invokes the following function: function selectHandler(event, data) { var myRequest = new Request.HTML({ url: '/Calendar/EventList', method: 'post', data: ...

Mozilla Firefox programmatic screen capture

Hi, I'm interested in writing javascript that will programmatically perform a screen capture of what is viewed in the browser, and save the file to the hard disk. I'd like to be able to type in a list of keywords, and use a search engine's api to programmatically view the page, and take a screen capture. My first question is, does this...