javascript

How can I find out the position of an item contained by an array?

I know the name of the item and would like to know its position in the array, how would I do that? ...

How could I delete an item from an array by the item's name?

Like I have an array Array('one', 'three', 'two');, and, say, I want to delete the item three, how would I do it? ...

Updating target href problem

I'm working on a little image gallery, where you'd roll over a small thumbnail, the larger image would display over it. Clicking on the image would load a full size version in an overlay. http://shopcoobie.server303.com/shop/ The issue is with the larger image, the rollovers are working fine, but the script I have updates the href whic...

What's up with document.domConfig on Firefox?

I was iterating over properties of document when I ran into an interesting phenomena in Firefox, document claims to support the property domConfig although MDC says it isn't implemented but when I try to retrieve the property I get an exception: Error: uncaught exception: [Exception... "Component returned failure code: 0x80004001 (NS...

Click event in Google Map InfoWindow not caught

With Google Map v2, I would like to be able to trigger a function when clicking a text in the InfoWindow of a GMarker. $(".foo").click(myFunction); ... marker.openInfoWindowHtml("<span class=\"foo\">myText</span>"); does not work. Why the event isn't caught inside the InfoWindow ? ...

Fix JQuery-1.4.1 and json-2.0 conflict in json.parse regex conflict with "$" character

After upgrading to jquery 1.4.1 i noticed there was an error anytime i tried calling json.parse. The issue is part of the regex used in json. it uses a $ in the pattern that conflicts with JQuery's $ shortcut. I don't want to use the non-conflict option with jquery because i have tons of places i'd have to replace the $ with the new cor...

How can I detect when a function is called as a jQuery callback vs. called directly?

I'm using hoverIntent which, as part of its settings, will call a function. I think this is called 'referencing a function' (correct?): var HIconfig = { interval: 250, sensitivity: 8, over: myFunction, timeout: 100, out: myOtherFunction }; However, I'd like to reuse said function at times and explicitly pass i...

Can't control Youtube embed even with document.getElementById('xyz').playVideo() - not a function?

OK, I'm stuck and I don't know what's wrong even after following Google's docs and reading suggestions here on Stackoverflow. Why can't I control Youtube embeds in my web page? If I create an HTML file with the <body> being: <object id="o1" width="480" height="295"> <param name="movie" value="http://www.youtube.com/v/qCTLCNmnlK...

Detecting Arrow key press in IE via javascript/jQuery

I'm trying to set up a menu that can be navigated via the arrow keys. I have this working fin in Firefox. Trying to get it to work in IE8 and after a bit of struggle, found that it was because IE8 wouldn't register a keypress on the arrows. To test: $(document).keypress(function (eh){ alert(eh.keyCode); }; In Firefox, pressing a...

<input type="text"> helper (fades out the text when user types) javascript

Hello, I want to add helpful text (in javascript WITHOUT ANY FRAMEWORK USE) in input fields text and textarea something like this but dont know what its called As it is used in me.com but I dont want to submit the values that are used as helpers. Sorry for bad english. Thank You. ...

callback structure

Hi, I'm a little confused about the best practice to achieve the following: I have an object which requires the load of 2 JS libraries(jQuery and swfobject), who may be already loaded or not, so i have to check both before calling the final method (output). Another tricky thing is that i have to pass some arguments to the initial metho...

Updating IFRAME src while embedded in Thickbox

Hi all, hopefully a simple question here. I'm running a Wordpress blog that has a bunch of links to different cities, which point to a location on a Google map. My current setup involves having an iframe for each link, and that iframe pops up in a thickbox when it is clicked. Now that my list of cities has grown, I have many, many ifr...

Positioning a div relative to mouse scroll position

All, On some mouse over, div1 is displayed.How to display the div next to the mouse pointer so that even mouseover at the end of the context the div should show up next to the mouse pointer. <style type="text/css"> #div1 { width: 200px; height: 30px; background-color: #a9a9a9; color: #fff; position: absolute; } </style> <script src="jq...

On what CDN is Google's Closure library hosted?

Google hosts a number of JavaScript libraries such as jQuery and dojo on their CDN. For some reason, their own Google Closure library does not seem to be included. Is there a hosted version of the Closure library? ...

Javascript Object / Function Question

I have an instance of a logging class "logger", this class has a function "log(txt)", which works. Now I am declaring a different class "Runner" and I pass it the logger instance in the constructor. Everything works until line 5, but line 7 does not write to the log: var Runner = function (logger) { // constructor: logger.log("this...

Define an event on iFrame element with jQuery

Hi, I try to define a live event on img tags store on a iFrame. For example, I would like obtain a simple javascript alert box when I click a image on my iFrame. Do you know how i can define the events for the iFrame, because I would like to put a thing like $('img').live("click",function().... but only for the elements on iFrame. Tha...

Fix a character to text input box using javascript/jquery

I am looking for a way to 'fix' a dollar symbol $ to a text input box eg <input type="text" value="$" /> but make it not possible for the default value to be removed, so that whatever the user inputs, there is always a $ symbol 'prepending' input. Cheers ...

Discrepancy in JSON.stringify of date values in different browsers

I have this code in an HTML page: alert(JSON.stringify(new Date())); I'm including the latest json2.js (2009-09-29 version) in my page to support older browsers without JSON.stringify(). I also have jquery-1.3.2.js included. I believe in newer browsers with native JSON support, it just passes through to the native JSON feature. Her...

JavaScript: Is window.spam a good practice?

I've noticed all over the place people mention "Just define a variable in the top of your JS code and it becomes global" in response to questions like, "How do I create a global variable from inside a function?". Most of the answers start by saying it isn't possible to achieve that. Of course it is possible to do this: <script type="tex...

JavaScript: If var statements are executed first, then why does this not work?

I tried the following in JavaScript (Firefox 3.5, Windows XP): (function(){ window.foobar = 'Welcome!'; })(); var foobar = 'PWN3D!'; alert(foobar); The output was 'PWN3D!'. Why did my code PWN me? I thought var name = value; executed first. ...