Click here to Skip to main content
15,891,033 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi all,

I need to get the current url of iframe (not the first source of iframe). If iframe is in same domain, then it's easy but iframe won't be in same domain. Also, I don't need to use only iframe anyother control will be work for me. Any ideas?

Thanks for your help.
Posted
Updated 24-Nov-11 4:12am
v3

1 solution

It depends Current Url of your IFrame is of the same Domain or not.

If the set Url is of the same Domain then you may try below code to get it.
JavaScript
var currentUrl = document.getElementById("MyIframeId").contentWindow.location.href;


But in case if it is set to some other Domain Url, For Example - "http://www.codeProject.com", then I doubt you will be able to get it.
 
Share this answer
 
Comments
mfozmen 17-Nov-11 10:29am    
Unfortunately it won't be same domain. However, I don't need to use iframe especially. Anyother control or hmtl tag can work for me.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900