javascript

JavaScript Cookie returns null values in IE6 Only

I have a page where I grab a value from the query string and add it into a cookie. The value is used for a couple of different items on the page. If the user returns to the page and the value isn't in the query string, the value is pulled back from the cookie. I have tried doing my own cookie setting and retrieval in JavaScript as well...

What is the best Javascript XML-RPC client library?

What is the best Javascript XML-RPC client library in your opinion and why? I'am making a JQuery app and I need to communicate with my xmlrpc server with it. Found following libraries, but I have no idea what are their pros and cons: http://www.zentus.com/js/xmlrpc.js.html http://www.scottandrew.com/xml-rpc/ http://phpxmlrpc.sourcef...

Benefit of using 'window' prefix in javascript

Are there any benefits to using the 'window' prefix when calling javascript variables or methods in the window object? For example, would calling 'window.alert' have an advantage over simply calling 'alert'? I can imagine using the prefix could give a small performance boost when the call is made from inside some function/object, however...

JavaScript variable scoping - persisting state?

Hi, I have the following setup, and I need to know how to persist state. 1.) An external web page uses ajax to load and display a .jsp file, which contains javascript. 2.) Once this rendering is complete, javascript in the .jsp file must be called to perform an action based on the results that occurred during rendering. Specifically, th...

Using Jquery: Comparing Two Arrays for ANY Match

I'm looking for a concise way to compare two arrays for any match. I am using this comparison to apply a particular style to any table cell that has matching content. One array is a static list of content that should be contained in at least one table cell on the page. The other array is being generated by JQuery, and is the text of al...

firefox plugin inorder to get the data from textbox

my problem is that, i what to develop a firefox plugin that extract data from the textbox and it has to be stored in some temporary memory. i didn't have any idea about plugin's So please give the solution in a detailed manner thank u.......! ...

JS: Get clipboard data

I'm trying to write a Javascript function to edit content from clipboard before pasting. Right now i got bound event 'paste' to function via JQuery. $(this.elementDoc).bind('paste', function(event){ self.OnPaste(event); }); But that's not important. Now i would like to get Data from clipboard, but i can't find out how. I would be g...

Ways to call a Javascript function using the value of a string variable?

I've seen this technique for calling a Javascript function based on the value of a string variable. function foo() { alert('foo'); } var test = 'foo'; window[test](); //This calls foo() Is this the accepted way to do it or is there a better way? Any cross-browser issues to worry about? ...

How can I tell if a jQuery node is at the beginning of its parent node?

Given the following HTML: <p><img id="one" alt="at beginning, return true" />Some Text</p> <p>Some <img id="two" alt="in middle, return false" />Text</p> <p>Some Text<img id="three" alt="at end, return false" /></p> How would I be able to tell that $("img#one") is at the beginning of its parent node? Ideally what I'm trying to do is ...

Hacking JavaScript Array Into JSON With Python

I am fetching a .js file from a remote site that contains data I want to process as JSON using the simplejson library on my Google App Engine site. The .js file looks like this: var txns = [ { apples: '100', oranges: '20', type: 'SELL'}, { apples: '200', oranges: '10', type: 'BUY'}] I have no control over the format of this ...

jquery selectors for plain javascript objects instead of DOM elements

I've just started using jquery and I'm really enjoying using selectors. It occurs to me that the idiom would be a very nice way to traverse object trees (e.g., JSON query results). For example, if I have an object like this: var obj = { 'foo': 1, 'bar': 2, 'child': { 'baz': [3, 4, 5] } }; I would love to be able ...

Opening SWFUpload dialog w/o using a flash button?

SWFUpload has a parameter where you specify the button to be clicked to open a dialog. Is there a simple way to manually open the dialog box without the use of the SWFUpload-provided button? Main thing is I have multiple places on my page where I want an image to be replaced via SWFUpload and I don't really want to instantiate a new SW...

When to use this in javascript OO?

In Javascript OO, when should I use the this keyword? Also, if I want to call a method of a class from another method of the same class, should I use this or just the name of the function? E.g is this correct? function Foo() { this.bar= function() { alert('bar'); } this.baz= function() { this.bar(); //should ...

jQuery smooth change of innerHTML

I have the code below working like a charm: var div = $('#div'); div.html('<div>one line</div><div>another line</div>'); div.slideDown('slow'); But the problem comes when I need to change the content (the number of lines): div.html('<div>one line replacement</div><div>another line replacement</div><div>third line</div>') This trans...

Getting the window size of the opener window (IE)

For FF and other non-IE browsers, window.opener.outerWidth/Height give me the info I need. For IE, I'm still at a loss, from IE6 to 8. I can't use jquery as the opener's page is beyond my control, so I can't do a window.opener.$(window). This requires the opener to have jquery 'attached' (correct me if I'm wrong). I googled quite a bit ...

Best way to store a key=>value array in Javascript?

What's the best way to store a key=>value array in javascript, and how can that be looped through? The key of each element should be a tag, such as {id} or just id and the value should be the numerical value of the id. It should either be the element of an existing javascript class, or be a global variable which could easily be referen...

Dynamically added SELECT element does not fire onchange event in Internet Explorer

As far as I can tell this only is only broken in Internet Explorer. I have a script that creates multiple dynamic <select> elements and adds an onchange event for them. The onchange event fires in Firefox with no problem but in Internet Explorer it never fires. Using Developer Toolbar I see the DOM has the correct event listed, it jus...

Replacing all occurrences of a string in javascript?

Say I have this string: Test abc test test abc test test test abc test test abc Doing str=str.replace('abc',''); Seems only to remove the first occurrence of abc in the string above. How can I replace ALL occurrences of it? ...

How do I scroll to the top of the page with jQuery?

I have a button a user presses and it shows a hidden div using jQuery. My question is, how do I scroll to the top of the page using a jQuery command in that function? It is desirable if the scroll bar instantly jumps to the top. I'm not looking for a smooth scrolling. ...

CSS/JavaScript Technique to dynamically force 2 divs to be the size of the larger div

I have 2 divs, a main content section and a sidebar. What I want to happen is force each div to be the same height as the tallest div If the Sidebar Content is taller then the Main Content I want to push the Main Content down to match the Sidebar Content's height +--------------------+----------+ | Main Content | Sidebar | | ...