i have a top frame with a webpage.


i have a bottom frame with the javascript. I'm trying to get the url of the top frame with javascript. the top frame id is link_frame. i'm trying get an alert box with the top frames url. the code i tried isn't working.

<a style='text-decoration: none' id='point' onclick='Url();'>Get</a>

<script type="text/javascript">
function Url()
{
var CurrentUrl = document.getElementById('link_frame').contentWindow. location.href;

alert("CurrentUrl");
}
</script>
var CurrentUrl = window.top.frames['frameName'].location.href;

replace 'frameName' with the correct name - assuming you have assigned a name attribute to the frame element.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.