SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Evangelist winterheat's Avatar
    Join Date
    Aug 2007
    Posts
    508
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Talking Possible to show an iframe's current location (current URL)



    Let's say if I do an iframe... is it possible to show the current location (current URL) of that iframe on the parent page if it has navigated outside of my domain? (that is... if i iframe and set the src to www.mywebsite.com, it seems that i can show the current URL of that iframe as long as the user is navigating within mywebsite.com. Once the user navigate outside of it, then i cannot show the iframe's current location using

    document.getElementById("an_iframe").contentWindow.location
    or document.getElementById("an_iframe").contentWindow.location.href

    hm... that's a bit strange, because it is just a URL.... and if i navigate in the main browser window, the URL is always visible in the browser's address bar, so why is there any security issue about it?)



  2. #2
    SitePoint Wizard chris_fuel's Avatar
    Join Date
    May 2006
    Location
    Ventura, CA
    Posts
    2,750
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hmm, yeah you can't do anything DOM wise with iframe contents if it's not inside the same domain (for security reasons). Does document.getElementById("an_iframe").src do anything for you?

  3. #3
    SitePoint Evangelist winterheat's Avatar
    Join Date
    Aug 2007
    Posts
    508
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    oh the src will only show the initial assigned value of url but not the current url. thanks so much.

  4. #4
    SitePoint Wizard chris_fuel's Avatar
    Join Date
    May 2006
    Location
    Ventura, CA
    Posts
    2,750
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hm, I can't really think of any alternatives given the scenario off hand. What is it that you're trying to accomplish? Maybe we can find another way that doesn't involve iframes, and could get done what you need.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •