1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

WORDPRESS Open External link in iframe?

Discussion in 'General Programming Chat' started by korfx04, Jun 24, 2013.

  1. korfx04

    korfx04 Junior Member

    Joined:
    Feb 27, 2009
    Messages:
    152
    Likes Received:
    96
    I'm trying to figure out how to open external links so it will show a small div at the top of the page with my logo and such and the external website under that. Much like how adfly does it. I know people use to do this with iframes, but isn't iframes obsolete?
     
  2. thedorf

    thedorf Senior Member

    Joined:
    Oct 1, 2008
    Messages:
    1,193
    Likes Received:
    700
    Occupation:
    what? I gotta have a job?
    Location:
    BHW - Where else?
    nope. Lots of people are doing that just like you described.
     
  3. innozemec

    innozemec Jr. VIP Jr. VIP

    Joined:
    Aug 19, 2011
    Messages:
    5,290
    Likes Received:
    1,799
    Location:
    www.Indexification.com
    Home Page:
  4. korfx04

    korfx04 Junior Member

    Joined:
    Feb 27, 2009
    Messages:
    152
    Likes Received:
    96
    Can this be done with wordpress though? like when the end-user clicks the title to the article on index.php, it then will open the link clicked in a new tab or out.php in a iframe?
     
    Last edited: Jun 25, 2013
  5. archert22

    archert22 Newbie

    Joined:
    Jun 26, 2013
    Messages:
    23
    Likes Received:
    2
    You can modify the word press themes however you like in the editor as you can modify the source code...

    Putting in an iframe should be relatively simple. If you want to open up a new tab on the title, just do something like...

    <a class='my_title' href='/your/site/here' target='_blank'><h1>This is my title<h1></a>

    Alternatively, if you wanted it to render in an iframe, ideally you'd have the iframe at in the page already like:

    <iframe src='/link/to/site' id='my_iframe'></iframe>

    Then, on your title, you can attach a jQuery / JavaScript event listener on it to render the iframe with new content on click. You'll have to double check as i'm doing this off of memory, but something like this.

    <script>
    $('.my_title').click(function(){
    iframe = $("#my_iframe").src = 'your_new_site';
    })
    </script>

    Something like that. Hope this helps!
     
    • Thanks Thanks x 1
  6. korfx04

    korfx04 Junior Member

    Joined:
    Feb 27, 2009
    Messages:
    152
    Likes Received:
    96
    Thanks archert22, i will give that a try. I'm still open to suggestions on the best way to do this.
     
  7. moijeishaianu

    moijeishaianu Newbie

    Joined:
    Jun 28, 2013
    Messages:
    15
    Likes Received:
    0
    in some way yes iframe is not good aproach because browser will limit it a lot with security and you will not be able to communicate with it via javascript, better one is using CSS styles with floating DIV