[SalesForce] For an Inline Vf Page how can I get the id of the current object

For an Inline Vf Page how can I get the id of the current object. I want to have the current object id . how can i retieve it use for an inline vf page.

I am embedding it in an Object A while the VF page points to the junction Object of A and B i.e., C. On the Controller, I need the object id Of A so that I may be able to save record of relating A and B.

Best Answer

If you have a controller, you could use ApexPages.currentPage().getParameters().get('Id').

If you have only Visualforce, you can use {!$CurrentPage.parameters.Id}

Or you can use JavaScript to read the parameters form the window.location.search property. Therefore the following function was helpful for me:

function getUriParams(paramName) {
    var params = decodeURIComponent(window.location.search.slice(1))
          .split('&')
          .reduce(function _reduce (/*Object*/ a, /*String*/ b) {
                b = b.split('=');
                a[b[0]] = b[1];
                return a;
          }, {})
    ;
    if(paramName) return params[paramName]; else return params;
}