#1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jan 2004
    Posts
    115
    Rep Power
    40

    Link in iframe to open in a new window in an iframe, but still on my page.


    I will explain it a bit.

    mysite.com has an iframe with some links in it.

    When you click a link in that iframe, it will open in the same iframe in mysite.com. This is not good, since I want one specific link in the iframe to open in a new window.

    Not only do I want this link to open in a new window, but the new window has to be a page of my own site, with an iframe which displays the result of the clicked linked of the iframe on my homepage.

    Hope you understand this, it's difficult to explain.


    I am not familiar with jquery but i've searched and found something that I thought may help me a little. This is the closest topic on the web that i could find:
    http://stackoverflow.com/questions/11193643/open-outgoing-link-in-iframe-by-default

    I've tried the basic codes listed there to start, but i don't even know how to implement that correctly on my pages. For instance, i tried this to start:

    On my index.php:
    Code:
    <a href="/result.php?link=http://www.google.nl">testlink.</a>
    On result.php:
    Code:
    <iframe src="<?php echo $_GET['link']; ?>" />
    As it says in the stackoverflow link i provided, but this doesn't work.


    Here is my testpage.
    http://www.onlineobjectives.com/vliegtest/

    The iframe can be called with javascript or with the regular iframe code as you can see. I don't care for one or the other, whichever one will work the best i'll use.

    If you select a flight and click 'zoeken' (which means 'search') - then it has to open the /result.php page, with an iframe which excutes the search.
    woozy.
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jan 2004
    Posts
    115
    Rep Power
    40
    Tried another way to get a bit of a start.

    This method works for everyone in this thread:
    http://www.codingforums.com/archive/index.php/t-85547.html

    But leaves me with a blank iframe on the new page.

    Confusion is complete right now.
    woozy.
  4. #3
  5. No Profile Picture
    Lost in code
    Devshed Supreme Being (6500+ posts)

    Join Date
    Dec 2004
    Posts
    8,316
    Rep Power
    7171
    When you click a link in that iframe, it will open in the same iframe in mysite.com. This is not good, since I want one specific link in the iframe to open in a new window.
    If you have a link inside an iframe and you want it to open in the parent window instead of in the iframe, you can do so by specifying the target attribute in the HTML a tag for the link:
    Code:
    <a href="#" target="_parent">link</a>
    Code:
    <a href="#" target="_top">link</a>
    If you want it to open in a new window, set the target to _blank.

    Not only do I want this link to open in a new window, but the new window has to be a page of my own site, with an iframe which displays the result of the clicked linked of the iframe on my homepage.
    Your approach with result.php is correct; you would simply modify the a tags to link to result.php instead of their original link.


    However, based on the way you worded your post, I'm guessing that you don't have control over the contents or <a> tags inside the pages in your iframe, and in that case what you're trying to do is impossible.
    PHP FAQ

    Originally Posted by Spad
    Ah USB, the only rectangular connector where you have to make 3 attempts before you get it the right way around
  6. #4
  7. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jan 2004
    Posts
    115
    Rep Power
    40
    Hm that's too bad. Thanks for clearing it up.
    woozy.
  8. #5
  9. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jan 2004
    Posts
    115
    Rep Power
    40
    One thing though. Even the simple codes when i do control the link don't work at all. How is that? For instance i changed the testpage now, check it out:

    http://www.onlineobjectives.com/vliegtest/

    Only code i've used is this:
    Code:
    <p>
    <a href="http://www.google.nl" target="vidframe">Dit is 3e test.</a>
    </p>
    
    
    
    <iframe name="vidframe" id="vidframe" src="" width='250px' height='250px'></iframe>
    why doesn't this even work? According to every source on the web this has to work.
    woozy.
  10. #6
  11. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jan 2004
    Posts
    115
    Rep Power
    40
    aha, i think it had to do with the google link I used as a test site. I used another site and it works, so nevermind.
    woozy.
  12. #7
  13. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jan 2004
    Posts
    115
    Rep Power
    40
    It doesn't look like they are willing to change the iframe. So here's what i was thinking to solve this:

    Page A:
    - mydomain.com/form/
    Where there is a form resembling the form the site in the iframe has. But this form is on my own site, with values resembling all the values of the iframe form. But the iframe with the 'original' form is not on this page!

    Page B:
    - mydomain.com/search/
    When clicking 'submit' on my own form on page A, it needs to go to this page B. Page B is also my own page, but here you will find the iframe. The form in the iframe needs to be filled & submitted automatically when someone fills and submits my own form on page A (matching form values).


    I think this would be possible, right? I'm a long time roboform user and this standalone program doesn't care if a form is in an iframe, it fills and submits everything automatically. I assume doing something like this on a website isn't working that much different?
    I am now looking into CURL as this looks like it would do what i want, never used it before though so it's new to me. Would this work?
    woozy.
  14. #8
  15. No Profile Picture
    Lost in code
    Devshed Supreme Being (6500+ posts)

    Join Date
    Dec 2004
    Posts
    8,316
    Rep Power
    7171
    The form in the iframe needs to be filled & submitted automatically when someone fills and submits my own form on page A (matching form values).

    I think this would be possible, right? I'm a long time roboform user and this standalone program doesn't care if a form is in an iframe, it fills and submits everything automatically. I assume doing something like this on a website isn't working that much different?
    No, that is not possible either. JavaScript from your website is not allowed to read or write data to an iframe if the iframe src points at a different website. All interaction between your parent page and the iframe page will be blocked if the domains of the URL are not identical.

    If this were not the case, then your original approach would have been possible because you could have dynamically modified the contents of the iframe to change the URLs of the <a> tags.

    The fact that roboforms is a standalone program is the reason why it can do this. A standalone program runs with full privileges on the user's computer. Your JavaScript code runs with extremely limited privileges.

    I am now looking into CURL as this looks like it would do what i want, never used it before though so it's new to me. Would this work?
    It IS possible to do this using cURL, or any server-side language for that matter. Effectively what you have to build is a proxy. The end user sends a request to your site, your site sends a request to the remote site, the remote site sends a response to your site, your site modifies the response and then sends it back to the end user.

    Not only does this allow you to modify the HTML contents of the iframe on the server-side, but because the iframe src will be on the same domain as the parent page, you will be able to interact between the two with JavaScript also.
    PHP FAQ

    Originally Posted by Spad
    Ah USB, the only rectangular connector where you have to make 3 attempts before you get it the right way around
  16. #9
  17. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jan 2004
    Posts
    115
    Rep Power
    40
    Originally Posted by E-Oreo
    It IS possible to do this using cURL, or any server-side language for that matter. Effectively what you have to build is a proxy. The end user sends a request to your site, your site sends a request to the remote site, the remote site sends a response to your site, your site modifies the response and then sends it back to the end user.

    Not only does this allow you to modify the HTML contents of the iframe on the server-side, but because the iframe src will be on the same domain as the parent page, you will be able to interact between the two with JavaScript also.
    Good news, thanks for the clear answers. I've got some work to do!
    woozy.

IMN logo majestic logo threadwatch logo seochat tools logo