javascript

JavaScript try/catch: errors or exceptions?

OK. I may be splitting hairs here, but my code isn't consistent and I'd like to make it so. But before I do, I want to make sure I'm going the right way. In practice this doesn't matter, but this has been bothering me for a while so I figured I'd ask my peers... Every time I use a try... catch statement, in the catch block I always log ...

javascript Date.parse

Case One: new Date(Date.parse("Jul 8, 2005")); Output: Fri Jul 08 2005 00:00:00 GMT-0700 (PST) Case Two: new Date(Date.parse("2005-07-08")); Output: Thu Jul 07 2005 17:00:00 GMT-0700 (PST) Why is the second parse incorrect? ...

Receiving name of the element as an object

This is my JavaScript code: <script> function change(name){ var element = document.all.name.value; } </script> It returns an error. How to pass to the function the element's name in order to change its value? ...

jquery draggable accept: classpath

Hi guys.. I have problems with the following bit of javascript/jquery code: this.droppable = function(){ $('.imageWindow .body .item').draggable(); $('.groupWindow .body .item').droppable({ accept: $(".imageWindow .body .item"), over: function(event, ui) { alert("this is valid!"); }, drop: f...

Avoid Browser Pop-up Blockers

Is there a set of best-practices or advice to avoid pop up windows being blocked by the different browsers pop-up blockers? By pop-up I mean windows created by either window.open or window.showModalDialog methods. Thanks a lot Edit: I do not plan to bypass the pop-up blockers with hacks. I came to this while developing an ...

How to design a JavaScript class to support callbacks in a clean way?

I've tried to design some classes to support a callback functionality. Classes MyClass1 and MyClass2 didn't work. Class3 worked, but the design is really horrible. It uses a external class reference to call the method. I'd like to implement a design similar to MyClass1, which is a lot clearer and isn't coupled to an external variable. Th...

cannot display json data returned from jquery ajax call

Hi, can somebody please tell me, how can I display json data returning from the ajax call. I am new to this. $.ajaxSetup({ cache: false, timeout: 5000 }); //String.prototype.toJSON; var the_object = {}; function concatObject(obj) { strArray = []; //new Array for (prop in obj) { strArray.push(prop + " value :" + obj...

Refering to javascript instance methods with a pound/hash sign

This question is similar to http://stackoverflow.com/questions/736120/why-are-methods-in-ruby-documentation-preceded-by-a-pound-sign I understand why in Ruby instance methods are proceeded with a pound sign, helping to differentiate talking about SomeClass#someMethod from SomeObject.someMethod and allowing rdoc to work. And I understand...

How is this site opening a new window

Normally we can specify a target in the link or use javascript window.open to open a new window. But when I access this site www.wenxuecity.com (It is a chinese site) I could't find out how it opens each news in a new window. no target in the link. debug javascript doesn't show any call to window.open Could someone tell me how it ...

Fetching content from Website on another Server

Hi everyone. What i basically want to do is to get content from a website and load it into a div of another website. This should be no problem so far. The problem is, that the content that should be fetched is located on a different server and i have no source access to it. I'd prefer a solution using JavaScript of jQuery. Can i use a ...

How to check if form input has value

Hi, I'm trying to check if a form input has any value (doesn't matter what the value is) so that I can append the value to the action URL on submit if it does exist. I need to add the name of the param before adding the value, and just leaving a blank param name like "P=" without any value messes up the page. Here's my code: function ...

Ext JS Web App Issues - Button Alignment on iPad

I am using the conventional css-class setup to place small icons at the left side of Ext buttons. On the iPad they are all misaligned, with the text overlapping them. On a side note, is there a simplified theme for Ext to reduce DOM nodes created? The UI is a bit sluggish. I was really hoping for better browser performance than I'm g...

Integrating legacy Ajax script in CakePHP

Hi, I have a legacy script that I would like to integrate in a cakephp app. The script makes use of $_POST and such and since I'm quite a noob I would need some help for the integration. Here is how the script looks like: THE JAVASCRIPT: prototype.js builder.js (these two are from the prototype fw) lib.js (makes a ajax requests to r...

YUI TreeView Selection destroyed on recreate.

I have a YUI Treeview that allows selection with checkboxes. After some operations, I destroy the tree (with tree.destroy()), and then create a new tree using the same containerID. This new tree should allow selection using checkboxes, but does not. What could be causing this? ...

Making JQuery horizontal accordion close on click

Example: http://vincent-massaro.com/map/ Currently, the script allows you to click on a piece of the accordion to open it, but it is set to close on mouseleave. When I set the mouseleave to .click, it gets confused and doesn't know what state it is in. I want to make it so that you can click to open it, and click to close it, instead of...

How to embed a google map with a changeable area?

I haven't worded this very well But basically, I'd like to embed a map on my site - but the area it shows will change. I've tried doing this, but it never seems to work as it will focus on the wrong area - the old area, rather than the new area. Basically, I'd like a google map code that uses $place as a location. Thanks. ...

How do I use JavaScript (not jQuery) to make something display:none?

Suppose I have an element called "#container-main". How do I make that display:none NOT using jQuery? ...

PHP/JS/JQUERY: Smart method to Auto check/updating a points status

Hello. Hi everyone. So right now I am using me of this: function checkpoints() { var postThis = 'checker.php?userid='+ $('#user_id_points').val(); $.post(postThis, function(data){ $(".vispoints").html(data).find(".vispoints1").fadeIn("slow") }); setTimeout(checkpoints, 5000); } This function repeats each 5 seconds (...

Resolve sibling folder in JavaScript Function

Hi, I am trying to pass into an JavaScript function two paths for an XML and XSLT. It would appear that in the sample HTML below that the use of "../xsl/filename" does not work for me in the xslt() function. If I specify the path as being "./filename" though this does work. Does anyone know how I can work around this or find some wa...

Mobile Safari Youtube opened via javascript

We have a youtube player embedded in a plage in Mobile Safari and it works great. But we need to be able to launch the youtube player by a means other than user tapping the video itself, for various reasons. So I am trying to figure out what event to trigger in javascript to make it happen with no luck. None of the following appear to...