SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Addict ruba's Avatar
    Join Date
    Apr 2005
    Location
    Amman -Jordan
    Posts
    339
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question get current iframe URL

    I have iframe in my website ..

    users browser links inside the iframe ..

    is there any way using javascript or jquery to know what is the current page url ??

    for example : .
    the iframe is google.com
    after users make search I want to get the search result URL .. can I ??
    Open Blocked website
    Open Blocked Website
    Knowledge Is Knowing That A Tomato Is A Fruit,
    Wisdom Is Not Putting It In A Fruit Salad.

  2. #2
    Gre aus'm Pott gold trophysilver trophybronze trophy
    Pullo's Avatar
    Join Date
    Jun 2007
    Location
    Germany
    Posts
    5,996
    Mentioned
    219 Post(s)
    Tagged
    12 Thread(s)
    Hi there,

    AFAIK this is not possible if the iframes are on different domains (e.g. google.com and mysite.com), as it falls foul of the same-origin access policy.

    However, if the iframes are on the same domain, then this should work:

    Code JavaScript:
    document.getElementById('myiframe').contentDocument.location;  // All good browsers
    document.frames['MyFrame'].document.location; // IE

    HTH


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
  •