2

I want create a web page like www.domain.com/iframe that load a cross-domain website on it like yahoo.com. visitor want browse on iframe page (yahoo.com) and my main page must always detect iframe url.

Because ross-domain iframe policy its not access it via

document.getElementById('myframe').contentWindow.location.href;

I do some googling on it, ways like jquery PostMessage , porxy ifrmae .... but It not work for me. my iframe is not on my access to add java functions.

I dont have coercion to use iframe, I want a technique to show an other link on my page and know position of that other view on my page to do some things...

please help me in this problem.

IrajTaghlidi
  • 23
  • 1
  • 4

1 Answers1

0

With jquery you can do it

<script src="http://code.jquery.com/jquery-1.9.1.js"></script>
Links: <br />
<a title="http://validator.w3.org/">w3c.com</a><br />
<a title="http://fr.wikipedia.org/wiki/Wikip%C3%A9dia:Accueil_principal">wiki in french</a><br />

<iframe id="myiframe" src="http://www.google.fr" width="100%" height="100%"></iframe>

 <script>
 $(document).ready(function() {

   $("a").click(function () {
     var $urls = $(this).attr("title");
    $("#myiframe").attr("src", $urls);
     return false;
  });
});
 </script>

.attr() will change the src="" of your iframe. Now you can just interact the attr with an event like on click or whatever you want.

Dorian_gd
  • 181
  • 1
  • 13
  • Hi,Thanks for reply.maybe I explain bad. please see my real page : http://bit.ly/1448O9S In top of page url pf iframe showed. I want whene user click on a link in iframe,in top page url changed.and flow it. thanks – IrajTaghlidi Jun 24 '13 at 08:48
  • i showed you how the script may be... Don't you know about jquery? if note check [link]http://jquery.com/ I will edit my post and show you a complete code. Please check again very soon – Dorian_gd Jun 24 '13 at 10:26
  • I am very thankful for your replies. I know jquery normal for use.Your code is : change Iframe src via main page via click event,... But I need inverse of that. here is a question like my need : http://stackoverflow.com/questions/8766281/getting-iframe-current-src-url-in-cross-domain I want reat an Iframe with a start link like yahoo.com. your click on Iframe links like yahoo images,.... inside iframe not on my main page, so I need trakc user iframe url, . – IrajTaghlidi Jun 25 '13 at 05:57
  • For some obvious security reason, it is impossible to interact from an iframe to the parent page – Dorian_gd Jun 25 '13 at 07:57