javascript

How to update a mysql database without reloading page

Hi, thanks for looking. I have a very long list of items, users click on an image (a plus sign) to add the item to their personal list. At the moment when they click the + it loads a "add-item.php?itemid=*" which processes the below code then redirects them to their own list, I did have it redirecting back to the global list but then it...

How do I pass the this context to a function?

I thought this would be something I could easily google, but maybe I'm not asking the right question... How do I set whatever "this" refers to in a given javascript function? for example, like with most of jQuery's functions such as: $(selector).each(function() { //$(this) gives me access to whatever selector we're on }); How d...

Access to "media keys" from within a browser tab

Is there a way to access the "media keys" with Javascript from within a browser tab/window? I am mainly interested in a google chrome solution. Using the following code, there doesn't seem to be an event generated for the media keys: <html> <body onKeyDown="showKeyCode(event)"> <script type="text/javascript"> function sho...

Javascript Modal Popup

I'm trying to create a simple modal popup. I have the CSS done, and the Javascript mostly done. I'm at the point where I click a button at the button of the page and the popup appears, but it appears at the top of the page. It appears excatly how it should if you were scrolled all the way to the top of the page. I however want the mo...

ExtJs - FormPanel not rendering properly

Hello guys! I have constuctor (window + formPanel) AddOrgWindowUI = Ext.extend(Ext.Window, { title: 'Create something', width: 400, height: 200, layout: 'fit', initComponent: function() { this.items = [ { xtype: 'form', id: 'add-form', padding: 5, initialConfig: Ext.apply(this...

Javascript file inclusion 406 error in CakePHP

Hi, I have several js files under webroot http://www.in-culture.info/app/webroot/js/ All the files are ok Eg http://www.in-culture.info/app/webroot/js/lightbox.js Except this http://www.in-culture.info/app/webroot/js/jquery.cookie.js It's throwing 406 Not acceptable error. Help please. ...

Preserving the function's scope when using function.apply(...)

Consider the following example: var funcToCall = function() {...}.bind(importantScope); // some time later var argsToUse = [...]; funcToCall.apply(someScope, argsToUse); I want to preserve 'importantScope' of funcToCall. Yet, I need to use apply to apply an unknown number of arguments. 'apply' requires that I provide 'someScope'. I d...

JavaScript is item a string

While looking at adding a trim function to the String prototype, I came across something that seems odd to me with JavaScript strings. if (typeof console === 'undefined') { var console = { }; console.log = function(msg) { alert(msg) } } function isString(str) { return ((str && typeof str === 'string') || ...

IE8 is submitting the form to the current page

It's working in all other browsers, and it was working on IE8 before, but I did some code cleanup and moved some things around, and now its submitting this form to it's self. It's an "ajax" uploader (yes, not really ajax, but you know what I mean) Here is the JS: function file_upload($theform,item_id){ $theform.attr('ACTION','io.cf...

HTML5 Canvas Transformation Matrix

I don't understand what the Transformation Matrix is and how to work with it. The following will draw a circle at 0, 0 of my canvas: (generated from an svg converted with svg2canvas.jar) drawPoints: function(ctx, max_points) { ctx.save(); ctx.setTransform(1, 0, 0, 1, -551.23701, -368.42499); ...

How to compare UTF-8 strings in Javascript?

When I wrote in JavaScript "Ł" > "Z" it returns true. In Unicode order it should be of course false. How to fix this? My site is using UTF-8. ...

SWFUPLOAD stuck on pending

Hi all, im trying to use swfupload on my website and have followed all the instructions to the bone. now, when i select a file, all i see is pending.. it never goes any further. here is my implementation var swfu = new SWFUpload({ upload_url : "urtupload.php", flash_url : "swfupload/swfupload.swf", flash9_url : "swfup...

Javascript open new window address bar still showing

Im having a problem where I click a link and it opens a new window in fullscreen mode, but the address bar is still showing which I don't want it to. Here is the code I have: function fullScreen(theURL) { window.open(theURL, '', 'fullscreen=yes, scrollbars=1, toolbar=0, location=no'); } Same problem in latest FF and IE8... ...

jquery: removing everything after an element

Hi, I have html code like this: <li> <a href=''>Example</a>&nbsp;<a href='' class='sub'>Edit</a>&nbsp;<a href='' class='sub'>Delete</a> </li> and I want to remove everything after the first </a>, including the spaces. What is the most elegant and simple way to do this? I have achieved my purpose with the following jquery: $('li').ch...

Javascript Object Literals and jQuery

I've updated the script here to give a better example. For $header I've got an anonymous function now returning $("#header"). Although this works I'm sure its not efficient as it calls $header every time it's used - so its the same as just using $("#header") throughout the code. What I really want is to store $("header") in a variable....

How to include javascript file in to dynamically created modal window?

I have a photo gallery that use modal window to display photos. During modal windows initialisation I'm inserting rest of photo functionality (share button, comment, tags, etc). Everything works well except facebook share button. From documentation you have to include following html code: <a name="fb_share">share</a> <script src="http:...

Design Patterns used in the jQuery library

jQuery is highly focused on the DOM and provides a nice abstraction around it. In doing so, it makes use of various well known design patterns which just hit me yesterday. One obvious example would be the Decorator pattern. The jQuery object provides new and additional functionality around a regular DOM object. For example, the DOM has...

javascript setAttribute 'className' works onLoad, but not onClick

Why does the following work for onLoad, and not onClick, and what would be the solution? Thanks in advance... <head> <title>Untitled Page</title> <LINK href=CSS/showdetails.css type=text/css rel=stylesheet /> </head> <body OnLoad="javascript:showdetails()"> <script language=JavaScript src=js/showdetails.js type=text/javascript>...

Need a regex for acceptable file names.

I'm using Fancy Upload 3 and onSelect of a file I need to run a check to make sure the user doesn't have any bad characters in the filename. I'm currently getting people uploading files with hieroglyphics and such in the names. What I need is to check if the filename only contains: A-Z a-z 0-9 _ (underscore) - (minus) SPACE ÀÈÌÒÙàèìòù...

Javascripts Object member access

Hi Folks, I'm wondering about access times on object members. More precisely, I'm benchmarking access times on the window object. I believe I can explain most behavior here on my own, but I'd feel better to hear some comments. Usecase: Different access times on different propertys ? I'm benchmarking on Firefox 3.6.8 (windows), the sim...