Here's a problem I'm having. I got my HTML page. In this page I have an iframe. The iframe is linked up to a page that I don't have control over, but what I want is that when someone clicks on a link in this iframe, that it replaces the what's in the iframe instead of opening a new window.

Is this even possible considering that I don't have control over the code that's contained within the iframe? If I do a view source on the page, I can see that they're doing a "target = _blank" to have this link open in a new window. Is there anyway to prevent this from happening? Thanks.

    I would use file_get_contents() to get the source code. Use regex to replace blank to self.

      Hmmm... So do a file_get_contents() on the HTML page, then replace the "blank" with "self" and that should work, huh?

      Hmmmm... I'm not using PHP for this particular part of the project. I wonder if there's an equivalent function in pl/sql. Do you know?

        hadoob024 wrote:

        Hmmm... So do a file_get_contents() on the HTML page, then replace the "blank" with "self" and that should work, huh?

        I doubt that there will be a function in php to so this. Have a go with file_get_contents() then ask on this forum for the regex once you have had a go at trying to get it to work.

        When you say replace, the regex with php would do this for you.

          Hmm... OK. So I do the file_get_contents(), then the regex, but then I need to write the contents of the string back into a file to use in the "SRC" part of the IFRAME tag, correct?

            You could make a separate PHP file that would grab the desired page via file_get_contents(), cURL, or whatever; modify it as desired, and then output it. Then use that PHP file as the src value of your iframe.

              Even easier you could use...

              <?php
              $file = file_get_contents("http://example.com");
              
              $file = str_replace("target=\"_blank\"","target=\"_self\"", $file);
              
              echo $file;
              ?>
                Write a Reply...