Jump to content

get url help


MDanz

Recommended Posts

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.  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>

Link to comment
https://forums.phpfreaks.com/topic/194757-get-url-help/
Share on other sites

You should be able to access it by using something like the following:

 

var CurrentUrl = top.getElementById('link_frame').location.href;

 

In the one case I had to do something like that, I did top.frameName.location.href;

 

I assume when you use document, it considers the current frame (or document) to be that, so hopefully top will do the trick.

 

And I just noticed this is "Solved", so nvm :o

Link to comment
https://forums.phpfreaks.com/topic/194757-get-url-help/#findComment-1024329
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.