WordPress.org

Ready to get started?Download WordPress

Forums

Advanced iFrame
[resolved] Open links within iframe in a new browser tab (6 posts)

  1. RetroTorque
    Member
    Posted 8 months ago #

    Hello,

    Using the advanced iframe plugin, is it possible to set things up so that any links clicked-on within the iframe open up in a new browser tab?

    I control the original content and it's on the same domain.

    (I could modify the links of the original content so they open in new tabs, but I'd prefer not to do that.)

    Many thanks,

    Mathew

    http://wordpress.org/plugins/advanced-iframe/

  2. mdempfle
    Member
    Plugin Author

    Posted 8 months ago #

    you can set the target dynamically by Javascript.

    e.g. jQuery('iframe a').attr('target', '_blank');
    Adopt this line to your needs.

    You can put this in the onload line. If you use any other onload options you have to add them there too. See the documentation of this line.

    Best, Michael

  3. RetroTorque
    Member
    Posted 8 months ago #

    Thanks for your help, Michael. Although unfortunately, I can't get this to work for some reason.

    Just to be clear, I've entered exactly:

    jQuery('iframe a').attr('target', '_blank');

    in the "Onload" box (in the Javascript iframe onload options). I've not encased the code with any <script> </script> tags.

    Clicking on any link within the iframe results in the iframe 'refreshing'.

    http://retrotorque.com/social-network/groups/club-retrotorque/

    The iframe is the one headed "Platinum Listings".

    I can't see any other setting which might be causing a conflict. Do you have any ideas, please?

  4. mdempfle
    Member
    Plugin Author

    Posted 8 months ago #

    have you changed anything? I don't see an iframe.

    I think you have to do this another way because the onload does escape some stuff. You need to put this into an function in an external js file and include the file. Than you can call this function in the onload setting.
    And as I said. you have adopt the Javascript to your html/id structure

  5. mdempfle
    Member
    Plugin Author

    Posted 8 months ago #

    I just have seen that the escaping should be fine.

    you still need to adopt the jquery

    e.g.
    jQuery("#advanced_iframe a").attr("target", "_blank");

    Best, Michael

  6. RetroTorque
    Member
    Posted 8 months ago #

    Thanks for your help Michael.

    I read up about 'adopting' jquery, but I still had a problem getting this to work. I'm sure it's simple, and I'm just missing something very basic.

    In case this helps anyone else - I've found another simple solution. Adding:

    target="_parent"

    to the links in the original content's php code results in the behaviour I need. The parent frame changes (i.e. the whole page), rather than the new page being loaded into just the iframe.

    Thanks again.

Reply

You must log in to post.

About this Plugin

About this Topic