Jump to content

How can Parent-html detect onNewPage in iframe-html , same-domain ?


vmars316

Recommended Posts

Hello ,

How can parent-html detect onNewPage in iframe-html , same-domain ?

Here is the Prototype of this scenario online:

http://vmars.us/Frames_Study/Which-Open-Links-In-iFrame-Which.html

or 


<!DOCTYPE html>
<html lang="en">
<head>
    <title>Opening Links in an iFrame</title>
	<style>
		iframe {
			width: 100%;
			height: 500px;
		}
	</style>
</head>
<body>

    <p style="text-align: center;">Communiation Between 'parent' and 'iframe Child' elements
	<br>On <a> Click in 'iframe' , Send Clicked Url to a 'parent' function .</p>
    <iframe src="SomeLocalLinks-00.html" name="myFrame"></iframe>
	
<script>
	var links = myFrame.document.querySelectorAll( 'a' );
	for ( var c = 0; c < links.length; c ++ ) {
         links[c].addEventListener('click', WhichLinkWasClicked);
      }
function WhichLinkWasClicked(evt) {
    alert( evt.target ) ; 
    evt.preventDefault();
		}
</script>
</body>
</html>

<!DOCTYPE html>
<html lang="en">
<head>
    <title>Opening Links from an iFrame</title>
	<style>
		iframe {
			width: 100%;
			height: 500px;
		}
	</style>
</head>
<body>

<br><br><a href="SomeLocalLinks-01.html">SomeLocalLinks-01</a>
<br><br><a href="SomeLocalLinks-02.html">SomeLocalLinks-02</a>
<br><br><a href="SomeLocalLinks-03.html">SomeLocalLinks-03</a>
<br><br><a href="SomeLocalLinks-04.html">SomeLocalLinks-04</a>
<br><br></body>
</html>

Thanks for your Help...

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...