Sandip's Programming Zen

An attempt to share tech/coding experiences

Posts Tagged ‘Javascript

Cross-Domain Calls with IFrames

with 2 comments

We know that cross domain ajax calls are not possible from javascript, but come’on we live in virtual world and every law can be bent if we can (remember Morpheus from ultra cool Matrix 😉 )

Ok, I found  here on this nice guy’s blog under Cross-Domain Communication with IFrames.

I have actually used it and it works like a charm. I made a simple javascript function to get the anchor values , actually I used anchors to pass values using URL as if passing URL variable.

For example if I want to pass one variable then I would do :

http://www.yourdomain.com#action=foo#

For two variables :

http://www.yourdomain.com#action=foo#action2=foo2#

Two JS function, one for getting anchor value and second for resetting URL to it’s original form.

function getAnchor(name) {

url = window.location.href;
var varlen = name.length + 2;
var start = url.indexOf(“#” + name) + varlen;
var length = url.indexOf(“#”, start) – start;

var value = url.substr(start, length);
return value;
}

function resetAnchor() {
url = window.location.href;
var hash = url.indexOf(“#”)
if (hash >= 0) {
url = url.substr(0, hash);
window.location.href = url + “#”;
}
}

I would be happy to help if you have any troubles.

Written by Sandip

April 29, 2009 at 4:37 pm

Posted in Internet, Javascript

Tagged with ,

JQuery

leave a comment »

In last week JQuery team has released their latest version.

JQuery is a open source light weight javascript library which contains features to interacts with HTML and DOM elements.

JQuery comes as a single javascript file and in order to use it you have to include it in your web page just as another .js file.

I found it very useful, first because it will save lot of time writing JS code and second, it will allow developers to add some user friendly features in their web apps in web 2.0 style.

Important features:

  • DOM element selections
  • DOM traversal and modification, (including support for CSS 1-3 and basic XPath)
  • Events
  • CSS manipulation
  • Effects and animations
  • Ajax
  • Extensibility
  • Utilities – such as browser version and the each function.
  • JavaScript Plugins

Visual Studio 2008 users cheers because you will find JQuery functions as part of Intellisense.

For more info and tutorials visit JQuery website.

Written by Sandip

February 12, 2008 at 5:23 pm

Posted in Programming

Tagged with , ,