Problem with starting script from iframe
Hi!
Guys, help me please.
There is a page with iframe, into iframe loaded page containing java-script. if I specify the source for the iframe
<
iframe
name
=
"iframe1"
src
=
"second.html"
><
/
iframe
>
everything works well, the script works on the parent window and the one in which he is. But if I try load page
into iframe with link
<a href="second.html" target="iframe1"> script don't work for a parent page. Script loses a parent? Please, see this code:
parent.html:
<html> <head> <title>first</title> <script language="javascript" type="text/javascript" src="jquery.js"></script> </head> <body> <iframe name="iframe1" src="second.html"></iframe> <a href="second.html" target="iframe1">load page</a> <p id="abc"> --- </div> </body> </html>
iframe page second.html:
<html> <head> <script language="javascript" type="text/javascript" src="jquery.js"></script> <script type="text/javascript"> $(document).ready(function() { $("#asd").text("CHILD WORK"); $("#abc",window.top.document).text("PARENT WORK"); alert("WORK OK"); }); </script> </head> <body> <div id="asd">-----</div> </body></html>
How to teach a script to see the main page and make changes to it (parent.html) ?
I will be very grateful for any help, thank you!