is this possible??? Iframe hit detection

Discussion in 'JavaScript' started by kool-aid, Aug 7, 2008.

  1. #1
    Hey guys + girls,
    O.K. I have to iframe something. I don't like to iframe in general, but in this case i have no choice. So I have a page iframed.

    What i want to know is there a way to detect when anything within the iframe is hit then refresh the whole page (not just the iframed area). I am pretty sure this is possible via Action Script, and i know javaScript is very similar. I am handy with Action Script, but never wrote java.

    Possible? Suggestions? Snippets?
    Edit/Delete Message
     
    kool-aid, Aug 7, 2008 IP
  2. xlcho

    xlcho Guest

    Messages:
    532
    Likes Received:
    8
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Put the fallowing code in the iframe source:
    
    <script type='text/javascript'>
    document.onclick = function() 
    { 
    	parent.location.reload();
    }
    </script>
    Code (markup):
    This will reload the whole page (not just the iframe) when you click anywhere on the iframe. If you need to reload the page only when a specific object inside the iframe has been clicked, then use the same function, but put the onclick event on the element that you want to be used, not on the 'document' element.
     
    xlcho, Aug 8, 2008 IP
  3. nabil_kadimi

    nabil_kadimi Well-Known Member

    Messages:
    1,065
    Likes Received:
    69
    Best Answers:
    0
    Trophy Points:
    195
    #3
    window.parent or window.top will access the topmost window object
     
    nabil_kadimi, Aug 8, 2008 IP
  4. kool-aid

    kool-aid Peon

    Messages:
    7
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Awseome thanks guys.
     
    kool-aid, Aug 20, 2008 IP