SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Enthusiast
    Join Date
    Jun 2008
    Posts
    33
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    How can I use onClick in <iframe>?

    Hello everyone,
    I'm trying to write a script that open a new window each time someone clicks on inside the <iframe>

    I'll give an example:
    <iframe src='http://www.google.com' onClick="myPopup()"> </ iframe>

    <script type="text/javascript">
    <-
    myPopup function () {
    window.open ("http://www.google.com/")
    }
    //-->
    </ script>



    Every time someone clicks on the iframe, the function myPopup should open a new window with Google site.

    The problem that onClick not working in iframe
    (If you try onmouseover for example, then it will work)

    How can I make it work?

  2. #2
    SitePoint Enthusiast
    Join Date
    Oct 2010
    Posts
    61
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You can't use onclick to open window with iframe !!!

  3. #3
    SitePoint Enthusiast
    Join Date
    Oct 2010
    Posts
    61
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I understand like :
    ------------------
    <iframe name="n" src='http://www.google.com'> </iframe>

    <br>
    <script type="text/javascript">
    function myPopup(){
    window.open ("http://www.google.com/")
    }

    </script>
    <input type="button" value="vietnamese" onclick="myPopup();"/>

    U can check !!!


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •