javascript

What are the disadvantages to using a PHP proxy to bypass the same-origin policy for XMLHttpRequest?

http://developer.yahoo.com/javascript/howto-proxy.html Are there disadvantages to this technique? The advantage is obvious, that you can use a proxy to get XML or JavaScript on another domain with XMLHttpRequest without running into same-origin restrictions. However, I do not hear about disadvantages over other methods -- are there, and...

How to get an error-code from a VB component into (serverside) JScript.

Hi all, I have an plain-old asp web site that makes a call to a method in a dll written in VB 6. This method sets an error code in the VB Err Object if something goes wrong. Now I want to access that error code and description set in the Err object from a javascript (where I do the call to the dll method). First: is it possible? Second...

What is the right way to change the behavior of an <a> tag?

I want to make a link call a Javascript function through the onclick event and not do anything else (follow the link). What is the best way to do that? I usually do this: <a href="#" onclick="foo()">Click</a> But I'm not sure that is the best way and in this case it is navigating to page.html# which isn't good for what I'm doing. ...

Testing the type of a DOM element in Javascript

Is there a way to test the type of an element in JavaScript? The answer may or may not require the prototype library, however the following setup does make use of the library. function(event) { var element = event.element(); // if element is and anchor ... // if element is a td ... } ...

Stripping out a link in jQuery

I have a bit of html like so: <a href="#somthing" id="a1"><img src="something" /></a> <a href="#somthing" id="a2"><img src="something" /></a> I need to strip off the links so I'm just left with a couple of image tags. What would be the most efficient way to do this with jQuery? ...

Why does this remote script cause IE6 to hang?

Please take a look at the html listed below and let me know why IE6 freezes when trying to load the remote script (located at 'http://code.katzenbach.com/Default.aspx'). The script returns JSONP and executes the 'callbackFunction' listed in the header. When it runs correctly, you'll see a pop-up alert showing numbers 1-500. This works...

How can I open a link in the default web browser from an HTA?

I'm working on an application that is implemented as an HTA. I have a series of links that I would like to have open in the system's default web browser. Using <a href="url" target="_blank"> opens the link in IE regardless of the default browser. Is there a way to use the default browser? Using JavaScript is an option. ...

How to use JSON to create object that Inherits from Object Type?

I know how to use JSON to create objects, but there doesn't seem to be away to use JSON to create an object that is of a specific object type. Here's an example of an Object and creating an instance of it: Person = function() { }; Person.prototype = { FirstName: null, GetFirstName: function() { return this.FirstName; ...

How can I concatenate regex literals in Javascript?

Is it possible to do something like this? var pattern = /some regex segment/ + /* comment here */ /another segment/; Or do I have to use new RegExp() syntax and concatenate a string? I'd prefer to use the literal as the code is both more self-evident and concise. ...

Javascript nested class

How do I define nested class in Java Script. Here is the code snippet I have: objA = new TestA(); function TestB () { this.testPrint = function () { print ( " Inside testPrint " ); } } function TestA () { var myObjB = new TestB(); } Now I am trying to access testPrint using objA objA.myObjB.testPrint(); But its g...

How Do I Detect the Adobe Acrobat Version Installed in Firefox via JavaScript

Title says it all. I know this can be done in IE by creating an ActiveX object, but how do I do it in FF. The navigator.plugins['Adobe Acrobat'] object lets me know if it's installed or not, but it doesn't contain the version number. Any ideas? ...

How to select a range of elements in jQuery.

<div id="myDiv"> <a>...</a> <a>...</a> <a>...</a> <a>...</a> <a>...</a> <a>...</a> </div> If you wanted to select the 2nd, 3rd and 4th a tags in the above example, how would you do that? The only thing I can think of is: $("#myDiv a:eq(1), #myDiv a:eq(2), #myDiv a:eq(3)") But that doesn't look to be ver...

How do you explain this structure in JavaScript?

(function() { //codehere } )(); What is special about this kind of syntax? What does ()(); imply? ...

What does it mean that Javascript is a prototype based language?

One of the major advantages with Javascript is said to be that it is a prototype based language. But what does it mean that Javascript is prototype based and why is that an advantage? ...

How to create nestable draggables in Scriptaculous?

I'm using the Scriptaculous library to slap an appealing UI on an application which helps an enduser build lists. Let's say its for pizza creation. To fill out an order, you drag a size of pizza from the pizza palette into the orders droppable. Once it is put in there, it gets replaced with a new div which is both draggable (because y...

Where in JavaScript is the request coming from?

I am debugging a large, complex web page that has a lot of JavaScript, JQuery, Ajax and so on. Somewhere in that code I am getting a rouge request (I think it is an empty img) that calls the root of the server. I know it is not in the html or the css and am pretty convinced that somewhere in the JavaScript code the reqest is being made...

How can I auto filter a HTML selectlist?

I have a HTML select list with quite a few (1000+) names. I have a javascript in place which will select the first matching name if someone starts typing. This matching looks at the start of the item: var optionsLength = dropdownlist.options.length; for (var n=0; n < optionsLength; n++) { var optionText = dropdownlist.options[n...

How to reimplement jQuery's default helper in a custom helper

I'm creating a custom drag helper (in jQuery): $('.dragme', element).draggable({ appendTo: 'body', helper : custom_drag_helper, opacity : 0.5 }); I'm doing this because I want to sometimes clone and sometimes do the default functionality, i.e. drag the original element. function custom_drag_helper() { if (/*criteria...

What is the best practice to use ExtJS with Asp.net and WCF in .NET 3.5?

How do you save data from ExtJS form? Load data from the business layer into form or grid? ...

Can I speed up the YUI layout manager, when I have a large table on the page?

I am using the YUI layout manager which seems to work at an OK speed. However if the page contains a large <Table> with about 500 rows, the YUI render() function takes about a minute longer to run. When I open the same page without the layout manager it opens in less than a second. My only concern is with IE 7. I tried it on firefox an...