Damien
Damien

Reputation:

Find page url with a function in my frame

I have made a html page and two website take it on her website like a frame.

I want to change the color of my frame. So i have to know witch website included my frame.

What function I have to use in javascript

Thanks

Upvotes: 0

Views: 338

Answers (2)

steamer25
steamer25

Reputation: 9553

try {
  alert(window.top.location);
} catch (e) {
  alert("Couldn't read window.top.location.\n" + e.message);
}

This may not work due to cross-site policies. Alternately, you could have some server-side logic dynamically insert a stylesheet based on request parameters.

E.g.,

http://mysite.com/iframeContent?useStyles=http://yoursite.com/iframe.css

Upvotes: 2

Ben Hughes
Ben Hughes

Reputation: 14195

I'd look into

window.frames

As that returns an array of frames within the current window.

This might also be of some help:

http://www.oreillynet.com/pub/a/javascript/excerpt/jstdg_ch13/index.html?page=2#winoverview

Upvotes: 0

Related Questions