0

I am able to capture the user navigations from an external website opened in an IFrame into a variable and i am able to display the location in console. But i want to capture all the user navigations into an array or a text file. Please help me with this. Below is the code i have.

<html>
<head>
<title>test page</title>
</head>

<body>

<li><a href="http://mysmallwebpage.com/" target="iframe_a">Small Page</li>

<iframe id = "frame" src="" name="iframe_a" onload ="loadImage()" width = 100% height = 100% style="border:none;"></iframe>

</body>

<script>

function loadImage() 
{

test = document.getElementById("frame").contentWindow.location; 

console.log(test);

}
</script>

</html>

The variable "TEST" in the script is holding the navigation link. I just want to capture all the navigations in some array or file. Please test the code using console understand my request.

1 Answers1

0

Create an empy array to hold the navigation history. You can dynamically add elements to the array using the push method.

Within your loadImage function, push the current location onto the end of the array.

var navigations = [];

function loadImage() 
{
    navigations.push( document.getElementById("frame").contentWindow.location );

}

For more information on JavaScript arrays read this article.

jla
  • 4,191
  • 3
  • 27
  • 44