[SalesForce] How to pass variables from Iframe to VF page URL? I’m displaying a vfpage in sidebar as homepage component

I have a visualforce page and a controller for it, already written. My requirement is to show the same page as one of the homepage components in the left sidebar, I did that by calling through an iframe, till now all working fine. When any page will get loaded, I want the url of the page not of the visualforce page which I have created. eg.'https://na12.salesforce.com/001/o' or 'https://na12.salesforce.com/home/home.jsp' but not the one like '/apex/mypagename'.

How to achieve this ?

<iframe src="/apex/HomePageComponent?core.apexpages.devmode.url=1" id="showskill" frameborder="0" height="100px" width="180px"> </iframe>

this is my iframe code, I want something like where I can pass a string, appending it to src probably this way, '/apex/mypage?id='+var

Best Answer

I managed to find the answer with the help of one of my friends, it was simple but really hard to find.

<iframe src="/apex/HomePageComponent?core.apexpages.devmode.url=1" id="showskill" frameborder="0" height="100px" width="180px"> </iframe>

I was doing the same stuff earlier also.. just found out something called Frame[0].location which helped me achieve the desired reqmnt.

<script> 
    var location = window.location;  
    var static_location = "/apexHomePageComponent?core.apexpages.devmode.url=1&src="; 
    var abs_url = static_location + location; 
    frame[0].location = abs_url; 
</script>

Now, from the Vf page's controller i can fetch the value of 'src' quite easily

Thank you so much Vishal for this. :)