javascript

How to convert a string into a map in javascript?

Say, we have a query string that looks like this: "param1:'test1' && param2:'test2'" I would like to turn it into an object map, like this: {param:test1, param2:test2} How could that be done? This seems like a very common use case. ...

Cant make a crossdomain Ajax call

hey, if i try this code $(document).ready(function(){ $.ajax({ url: "http://gdata.youtube.com/feeds/api/users/zdf/playlists?v=2", type: "GET", success: function(msg){ console.log(msg); } }); }); i get this error "XMLHttpRequest cannot load http://gdata.youtube.com/feeds/api/users/zdf...

Caching problem with asynchronous javascript loading with onload event

Hi guys, I am currently trying to load some js files asynchronously, so that they are not able to block the rest of the website. I mainly followed the descriptions found here: Asynchronous Javascript In terms of the non blocking loading of the javascript file this works great, but i got now the problem that the javascript file is cac...

Show and hide iframe that is sized to content

Hey i have a iframe that i am sizing to its content with the following script. I want to show and hide this iframe with two buttons but when its hidden the iframes width and height is not calculated and so when i click the show button it does not show because the width and height are still set to 0. I am pretty new to jquery and javasc...

jQuery datepicker date range throwing invalid date range error with valid dates

Hi, For some reason when i enter the following dates into the following fields it is returning an invalid date range and i am not sure why: http://jsfiddle.net/mQRaj/3/ To replicate please enter the following in the 'From' date: 30/11/2009 and then this in the 'To' date: 7/9/2010 Bur if i enter 16/11/2009 and 7/9/2010 it does not ...

How do I hide broken images in javascript?

I have my image inside an if statement: if (item.image) historyHtml += '<a href=' + item.image + ' class="image" target="_blank"><img src="' + item.image +'" width="111px"/></a>'; Thank you! :) ...

Show the title of <a> link in a div not in a tool tip

How i can show the title of this <a href="www.google.com" title="google" onclick="search.php" target="_blank">google</a> on mouse on, I want show it in a div and not in the basic tooltip how? I think its easy to show but i dont know how to hide the original browser tooltip Is there a way to do this in JavaScript, or in jQuer...

Simple Javascript Slider

Im trying to find a very very simple javascript slider. One that is the bare minimum, no fancy jquery, or other libraries involved. The simplest possible slider. With the minimum amount of code possible. Thanks for the attention! @ Roger Walsh: Below the HTML code: The .js and the .css are identical to the example in the tutorial you...

Is there a tool for formatting javascript that doesn't suck?

I am looking for a tool that formats my javascript for me. There are many times when I wish I could just let a tool format my source code because of restructuring some code or because I want to make sure the code structure really is like I believe it to be. My problem is that all formatters I have found produce really retarded results. ...

override :first-child pseudo class styling using jquery

Hi, I need to override the defined :last-child style defined in my stylesheet using jQuery. I'm aiming for minimal markup using a combination of css and jQuery where the structure around "container-content" is appended to the div on document-ready. <div id="title-some-impact"><!--Vertical container title--></div> <div class="contai...

Submit form when enter key pressed using Prototype javascript

I've seen some other questions around this, but none for Prototype. I have a form without a submit button (uses a styled link that calls some javascript). What's the best way to detect a enter keypress in all the input fields and submit the form? Thanks! ...

Enter Key Detect + Null Value Then Form should not be submitted

I have two text field as mandatory and rest of the of the fields are normal. Now i have to detect enter key and submit the form. I have done that but the issue is that when error occurs (for example : fields are null) then i have to stop submitting the form but still form is submitting. <input autocomplete="off" type="text" id="first_n...

IE Printing changes absolute position

In internet explorer 6+, I am trying to make a mark on the left border where an element appears in the text. This currently works by putting an image at the absolute position with an X of 5px and a Y which is the absolute position of the element, worked out by navigating up the offsetParents and margins of all the parents up to the root....

separation of logic and UI in titanium (javascript)

Hi folks, i'm new to appcelerators titanium and javascript and i'm interested in coding an iphone app. i recognized that there is a need of "many" code for creating the UI. that's no problem so far, but i tend to separate that code from my application logic wisely. what are the best practices? ...

JavaScript syntax doubt? (mootools)

EDIT: This got way too complicated, I will migrate this question to another question and put up my new code there! Please ignore the code on this because it is logically flawed. (Please vote to close the question as it makes no sense) Hi, I am initializing the following loops in my code. The code is written using mootools. CANVAS.init...

find out the parent of a link and pre-pend it with somethin

I'm trying do something like this if ($(this).parent() == $('div.propdata')){ $(this).prepend('<a class="booknow2 sidelink" href="../../availability/default.aspx"><span>Book now &raquo;</span></a>'); } By the way $(this) is evenprop Can't seem to get it to work This is my code <div class="propdata" id="FARM"><div class="evenprop...

Jquery: Add class to every second visible element.

I'm trying to create a dynamic portfolio gallery where you can hide show items by clicking categories. Everything works apart from adding a class to elements hidden/showing when categories are clicked. I currently have: $(document).ready(function() { $('ul.filter a').click(function() { $(this).css('outline','none'); $('ul.filter ....

Javascript working on Firefox but not in Chrome and IE6

I have javascript that working fine in Firefox 3.x.x, but it does not work in IE*, Chrome, Safari. Simple alert work before calling function. Here is the code function showDiv(div){ //alert(div); document.getElementById(div).style.visibility='visible'; document.getElementById(div).style.height='auto'; document.getElementById(div).s...

Creating two <img> elements while using one MotionJPEG stream

Hi, I'm trying to make a page that would display several MotionJPEG image thumbnails. When a thumbnail is clicked, its contents are shown in a larger image element as well. The problem is that when I try to use the same MotionJPEG stream for both a thumbnail and the main view (setting the main image's src attribute), the data never arr...

Flash, Facebook & permissions - JS, PHP or AS3 SDK

Setting out to develop a Flash quiz application for Facebook, which SDK (JS/PHP/AS3) and Facebook API (Graph/old rest) should I choose? Please also answer how the following would be accomplished using the preferred solution above and why this simplifies the development of the app: Authenticating user on app page Requesting permission ...