Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

highlight words in a page with an extension to the URL

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.

like image 940
james.bcn Avatar asked Nov 14 '22 08:11

james.bcn


1 Answers

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.

like image 65
Kenny Cason Avatar answered Dec 09 '22 18:12

Kenny Cason