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
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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

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