Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    Regular Coder
    Join Date
    Apr 2010
    Posts
    118
    Thanks
    6
    Thanked 0 Times in 0 Posts

    Using onClick over an iframed area?

    I have some ads that show on my pages. They are like Adsense (i.e. you place a javascript code on your page and the contents of that are an iframe).

    These ads always open in a new window when clicked. Obviously, that leaves my page intact ... but I don't want that. What I want, is that a visitor has clicked on an ad, the page refreshes so that new ads show.

    I tried:

    Code:
    <div onclick="window.location('/mypage.php"><script src="http://myadvertiser.com/code.js"></script></div>
    Thinking that would allow the advertiser's site to open in the new page as it is set to do, then in the background, my page would refresh.

    It didn't work.

    Any ideas?

    Thanks
    Mike
    I've been making animations for my daughter. Tell me what you think!

    Pickles and the Bully
    Where are you Pickles!?!

  • #2
    Master Coder felgall's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, Australia
    Posts
    6,471
    Thanks
    0
    Thanked 634 Times in 624 Posts
    Any iframe content from a different domain cannot be accessed from scripts running in your page unless the other domain also has scripts running to handle that half of the communication.
    Stephen
    Learn Modern JavaScript - http://javascriptexample.net/
    Helping others to solve their computer problem at http://www.felgall.com/

    Don't forget to start your JavaScript code with "use strict"; which makes it easier to find errors in your code.

  • #3
    Regular Coder
    Join Date
    Apr 2010
    Posts
    118
    Thanks
    6
    Thanked 0 Times in 0 Posts
    So there is no way to do it? You can't map out an area on the page over the top of an iframe?

    Or failing that, when the visitor "leaves" the page and is viewing the advertiser's site in a new window/tab - can my webpage "know" that has happened and therefore refresh?
    Last edited by instaunt; 03-20-2013 at 01:03 PM.
    I've been making animations for my daughter. Tell me what you think!

    Pickles and the Bully
    Where are you Pickles!?!


  •  

    Posting Permissions

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