Open link from Iframe in new window/tab?

5 replies
I have installed a php search engine on one of my sites which is viewed on several other pages using an iframe. My question is, once the search engine has listed the relevant pages, is it possible that when a page link is clicked it will automatically open in a new window or tab. I know this can be done on mass with wordpress just by installing a plugin, but can it be done with a php search results page?
#iframe #link #open #window or tab
  • Profile picture of the author KirkMcD
    Edit the code to modify the links to open in a new window.
    {{ DiscussionBoard.errors[9052333].message }}
    • Profile picture of the author yourstores
      Originally Posted by KirkMcD View Post

      Edit the code to modify the links to open in a new window.
      Easy for you to say. I wouldn't have a clue where to begin.
      {{ DiscussionBoard.errors[9052445].message }}
      • Profile picture of the author David B
        You would need to examine the code provided by the plugin. Sometimes in WordPress the plug-in configs allow you to modify some code in the plug-in administration screens, otherwise you will have to look in the directory where the plug-in was installed by WordPress for the actual php scripts for the plug-in.

        Then you would find the code for the result links. E.g.
        < a class="linkresult" href="someresult.html"> Some result page </a>

        And maybe add some javascript and change it to pop it up in a new window instead. Like:
        < a class="linkresult" > Some result page </a>
        <script type="text/javascript">
        $("a.linkresult").on("click", function (){
        window.open ('someresult.html','_blank');
        });
        </script>


        With variables likely instead of a hard coded url like someresults.html

        If you don't know php coding or don't want to get a programmer then unless the plug-in provides some configs in its administration screen you are probably out of luck.

        Hope this helps.

        David
        {{ DiscussionBoard.errors[9052715].message }}
  • Profile picture of the author kdavies
    You would need to add some javascript to add the "target" attribute to the links you want to open in a new tab/window. And you would need to make sure that all such links had the same class or some attribute that you could use to identify them.

    Using the YUI 3 javascript library something like:

    Y.all('.links').setAttribute("target","_blank");

    And you would need to do this by accessing the iframe of course.
    {{ DiscussionBoard.errors[9053037].message }}

Trending Topics