/    Sign up×
Community /Pin to ProfileBookmark

get URL from an IFRAME

Hey guys,

I posted this answer yesterday. Basically I wanted to extract the URL from inside an IFRAME. We can’t put a script into the IFRAME because it’s not our site inside.

I received the following answer:

<html>
<head>
<title>untitled</title>
<meta http-equiv=”content-type” content=”text/html; charset=iso-8859-1″>
</head>
<body>
<iframe src=”foo.html”></iframe>
<a href=”#” onclick=”alert(frames[0].location);”>Get iframe location.</a>
</body>
</html>

This works like a charm, but only for a site on my own webserver ( [url]http://localhost…[/url]) but not if it’s extern on the internet.

Anyone know the answer to this nut, please respond.
Thanks

Suha

to post a comment
JavaScript

5 Comments(s)

Copy linkTweet thisAlerts:
@96turnerriFeb 13.2004 — <html>

<head>

<title>untitled</title>

<meta http-equiv="content-type" content="text/html; charset=iso-8859-1">

</head>

<body>

<iframe src="foo.html"></iframe>

<a href="#" onclick="alert(document.frames[0].location);">Get iframe location.</a>

</body>

</html>

make sure the frame you want the source of is the first frame on the page
Copy linkTweet thisAlerts:
@suhaauthorFeb 13.2004 — that's ok,

this script works. It's the only frame on the site.

only, when inside the frame a site like www.somewhat.com is, the script didn't works.
Copy linkTweet thisAlerts:
@96turnerriFeb 13.2004 — yes thats because it is now the second frame on page therefore has to be

document.frames[1].location
Copy linkTweet thisAlerts:
@fredmvFeb 13.2004 — [i]Originally posted by suha [/i]

[B]only, when inside the frame a site like www.somewhat.com is, the script didn't works.[/B][/QUOTE]
http://www.mozilla.org/projects/security/components/same-origin.html
Copy linkTweet thisAlerts:
@DaRocknessAug 07.2008 — [CODE]<html>
<body>
<script language="JavaScript">
function myLocation() {
alert(document.all.myFrame.contentWindow.location);
}
</script>
<iframe id="myFrame" src="http://www.java2s.com" style="width:200;">
</iframe>
<br>
<button onclick="myLocation();">Location of Frame</button>
</body>
</html>[/CODE]


Ok, the above code does work; the problem you all are receiving is apparently a security problem with your web provider. I think, from what I read MicroSoft has implement some restrictions against IFrames for some reason, I guess this was to stop the Autobots ? from running around and collecting data; which is kinda retarded because that is what they are supposed to do; but I guess some sites don't want people looking at their work - fine whatever.

So if you get an "access denied" error it's because your Network Guy or Gal decided to implement IFrame security restrictions on your host machine.

I'm running into that problem with my free web page junk, and it's really annoying.

Anywho good luck.

  • - DaRock


  • "Send me sexual sexy girls for me, and a million dollars! "

    P.S. I'm trying to get around the problem by looking at the window.status property. However, does anyone know how to view the "actual" window.status label? Apparently it won't grab the data that is there, it only lets me capture the data I forced to the status property; which suggest the .status property and the window.status label are two different things.

    This makes me think that the onMouseover of an href, is not stored in the window.status but is somehow interchanged or interlaced with the window.status property; I want to get to that data anyone know what that is?

    So I think the display in the lower left corner is not the window.status variable - rather it's more like window.status label (or something along those lines) and window.status + window.onHrefMouseover (some variable I made up) is updated to.

    Again, Any ideas on how to get the "actual" display property information of the label? Or are we all being dupped again by another Microsoft'ism?
    ×

    Success!

    Help @suha spread the word by sharing this article on Twitter...

    Tweet This
    Sign in
    Forgot password?
    Sign in with TwitchSign in with GithubCreate Account
    about: ({
    version: 0.1.9 BETA 6.17,
    whats_new: community page,
    up_next: more Davinci•003 tasks,
    coming_soon: events calendar,
    social: @webDeveloperHQ
    });

    legal: ({
    terms: of use,
    privacy: policy
    });
    changelog: (
    version: 0.1.9,
    notes: added community page

    version: 0.1.8,
    notes: added Davinci•003

    version: 0.1.7,
    notes: upvote answers to bounties

    version: 0.1.6,
    notes: article editor refresh
    )...
    recent_tips: (
    tipper: @nearjob,
    tipped: article
    amount: 1000 SATS,

    tipper: @meenaratha,
    tipped: article
    amount: 1000 SATS,

    tipper: @meenaratha,
    tipped: article
    amount: 1000 SATS,
    )...