[Chicago] make some text a link via css or javascript

Warren Lindsey warren.lindsey at gmail.com
Fri May 15 04:21:27 CEST 2009


If you can't change the html of the page you're viewing, then put your
javascript function into a bookmarklet.  The you can run it against
any page.

Some examples on this page cover opening new links with highlighted text.

http://bookmarklets.com/tools/data/index.phtml

Cheers,
Warren

On Thu, May 14, 2009 at 2:20 PM, JS Irick <hundredpercentjuice at gmail.com> wrote:
>> Regular expressions are built into JavaScript. Here's an example that will
>> do what you want.
>> var re = /ticket#(\d+)/g
>> var text = "See ticket#123 and ticket#124"
>> text.replace(re, '<a href="http://example.com/trac/ticket/$1>ticket#$1</a>')
>
>
> Tsk, tsk spent too much time making the mockup and got beaten to it.
>
> The one thing to add is to use innerHTML, and call the function in the
> body's onLoad() method.
>
> <head>
> <SCRIPT type="text/javascript">
> function replacer(){
>   var re = /ticket#(\d+)/g
>   document.getElementById("area").innerHTML=document.getElementById("area").innerHTML.replace(re,
> '<a href="http://example.com/trac/ticket/$1>ticket#$1</a>')
> }
> </SCRIPT>
> </HEAD>
> <body onLoad="replacer()">
> <DIV ID="area">
> I'd like to point your attention to ticket#12
> </DIV>
> </body>
> _______________________________________________
> Chicago mailing list
> Chicago at python.org
> http://mail.python.org/mailman/listinfo/chicago
>


More information about the Chicago mailing list