Archive for the ‘JavaScript’ Category
javascript: Get parent window location href from an iFrame
Monday, February 22nd, 2010Assuming the iframe is from the same domain that the top window, use frameElement.ownerDocument to get to the parent document.
var topWindowHref = window.frameElement.ownerDocument.location.href
javascript: Remove items from an array
Monday, February 22nd, 2010From John Resig Javascript array remove
Array.prototype.remove = function(from, to) {
var rest = this.slice((to || from) + 1 || this.length);
this.length = from < 0 ? this.length + from : from;
return this.push.apply(this, rest);
};
Examples:
// Remove the second item from the array array.remove(1); // Remove the second-to-last item from the array array.remove(-2); // Remove the second and third items from the array array.remove(1,2); // Remove the last and second-to-last items from the array array.remove(-2,-1);
JavaScript: JSONP Quick Ref & Service List
Sunday, January 17th, 2010JSONP quick sample with Twitter
var tweeturl = "http://search.twitter.com/search.json?count=2&q=HAITI&callback=?";
$.getJSON(tweeturl, function(data){
$.each(data.results, function(i, item) {
$('<p></p>')
.addClass(i%2 ? 'even' : 'odd')
.html(item.text)
.prepend("<img src='" + item.profile_image_url + "' />")
.appendTo('#testDiv');
});
});
Result:
{
"results":[
{
"profile_image_url":"http://a1.twimg.com/profile_images/339499068/LaCroixLogoBlu2_normal.jpg",
"created_at":"Mon, 08 Mar 2010 02:16:46 +0000",
"from_user":"LaCroixChurch",
"to_user_id":null,
"text":"Geaux Haiti! "Far Away" by Lecrae... Powerful song for a honorable cause. Keep praying for Haiti brothers and... http://bit.ly/bbc7Za",
"id":10148624077,
"from_user_id":31526514,
"geo":null,
"iso_language_code":"en",
"source":"<a href="http://www.facebook.com/twitter" rel="nofollow">Facebook</a>"
},
.....
Services supporting JSONP
Feel free too add new one as comment I will update this page
Javascript: Date library datejs
Friday, September 4th, 2009HTML: AJAX Modal Dialog Box
Wednesday, March 25th, 2009Here are some JQuery puglins for creating Modal Dialog Box:
- Facebox: Facebook L&F, does have some images for corners.
- SimpleModal: Seems simple and lightweight.
- ThickBox: Seems complete but quite heavy (also, not very well maintained, last change log was from 2007).
See also:
Dojo: config settings
Saturday, October 4th, 2008Add the djConfig to the script tag.
<script type="text/javascript" src="dojo-directory/dojo.js"
djConfig="isDebug: true, parseOnLoad: true"> </script>
djConfig="isDebug: true, parseOnLoad: true"> </script>
For complete list of variables check out the dojo/_base/_loader/bootstrap.js file.
Click here to see the one in trunk.