Tutorial :Find page url with a function in my frame



Question:

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


Solution:1

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  


Solution:2

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


Note:If u also have question or solution just comment us below or mail us on toontricks1994@gmail.com
Previous
Next Post »