Search Results

Search found 1 results on 1 pages for 'evanwong'.

Page 1/1 | 1 

  • Track only iframe history

    - by evanwong
    I have a page which contains an iframe and I want to track the history of the iframe only. I tried to use the history object like this: <!DOCTYPE html> <html> <head> <title></title> <script type="text/javascript"> function checkFrameHistory() { alert(window.frames["test2"].history.length); } function checkThisHistory() { alert(history.length); } </script> </head> <body> <iframe name="test2" src="test2.html"></iframe> <div> <input type="button" onclick="checkFrameHistory()" value="Frame history"/> <input type="button" onclick="checkThisHistory()" value="This history"/> </div> </body> </html> test2.html <!DOCTYPE html> <html> <head> <title></title> <script type="text/javascript"> function checkMyHistory() { alert(history.length); } </script> </head> <body> <div> Test2 </div> <div> <input type="button" onclick="checkMyHistory()" value="My history"/> </div> </body> </html> but it actually gave me the history including the parent window. For instance, I went to another site in the main window and came back to my iframe test site. Both window.frames["test2"].history.length and history.length still gave me the same count by increasing the length by 2. Did I do it wrong? Is there a way to track only the iframe history?

    Read the article

1