views:

28

answers:

2

I have written a php script that generates a list of links that match certain criteria.

I want the links to open in a new browser windows with selected words highlighted in the page.

Is there an easy way to do this? Note that this is for personal use only, so it can be a browser specific solution.

A: 

the link you create can take ?variable=word . then on the new page you can use a $_GET to receive the word and with css highlight it

Sotiris
Sorry you are misunderstanding me. The linked-to pages are external ones, not ones I have generated by PHP.
james.bcn
A: 

Edited to better answer question.
Use AJAX to load the page and then process the returned HTML. I prefer using JQuery. Check out this tutorial for loading HTML from other pages. http://css.dzone.com/articles/jquery-load-data-from-other-pa
After you get the data I think you can easily figure out how to parse it

The JQuery example from the link,: (not My code)

<div id="container">
<a href="#" id="loadData">Click This Link To Load My Favorite Movies</a>
</div>
    $(document).ready(function()
     {
      $("#loadData").click(function()
       {
        $(this).text("...One Moment Please...");
         $("#container").append('<div id="favoriteMovies"></div>')
                        .children("#favoriteMovies").hide()
                        .load("theOtherPage.htm ul#favoriteMovies", function()
                         {
                          $("#loadData").remove();
                          $("#favoriteMovies").slideDown("slow");
                         });
       return false;
       });
    });

The page being loaded:

<ul id="favoriteMovies">
<li style="font-weight: bold; list-style-type: none;">My Favorite Movies</li>
<li>Contact</li>
<li>Shawshank Redemption</li>
<li>Napoleon Dynamite</li>
<li>Back To The Future</li>
<li>The Goonies</li>
<li>Cinderella Man</li>
<li>Apollo 13</li>
</ul>

Note: please somebody let me know if I should not post code from another site, but instead only post a link. I do not wish to anger anyone. thanks.

KennyCason
Thanks, that's good but not exactly what I am looking for. I want to highlight words on external pages in the simplest way possible, without having to parse them in PHP.
james.bcn
Is the external page a page that you are generating, or another website's page that you are wanting to highlight text on?If that is the case you can grab the contents of the page with Javascript/AJAX and parse it that way.
KennyCason
Ok, I think I see what you mean, I deleted the php references. Since you will probably want to use JQuery for this. If i have some free time I'll code up a demo for you.
KennyCason
I also know this doesn't directly solve your issue with opening them up in separate windows. but I hope it helps you with at least highlighting text from external pages.
KennyCason
Thanks, I'll experiment with this.
james.bcn
I just noticed the the <div id="container"> ... </div> wasn't showing in my previous answer, so i edited it.
KennyCason