Add rel = nofollow to all outgoing (external) hyperlinks using JQuery

On web applications like wiki & social networking websites where the users are allowed to add content, the developers cannot rely on the users to add rel=nofollow to each of these external links. Not adding rel=noffolow affects your application’s SEO rankings.

Here’s a simple approach using JQuery to add rel=nofollow to all external links on any given page.


DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
    <title>Add rel=nofollow to all external links using JQuerytitle>
  
    <script type="text/javascript" src="jquery-1.2.1.js">
    script>

    <script type="text/javascript">
    // the following function (document.ready) will be called each time the page      //is loaded
    $(function()
    {
        $("a[href^=http://]").attr("rel","nofollow");
        $("a[href^=http://]").css("background-color","yellow");
     });
    
    script>
head>
<body>
    <a href="http://www.cachinko.com">Cachinkoa><br/>
    <a href="http://www.google.com">Googlea><br/>
    <a href="www.Yahoo.com">Yahooa>
body>

Comments

Popular posts from this blog

WPF How to Dispose ViewModel when the associated UserControl (Not Window) closes?

C# How to unit test Dispatcher

WPF: How to Deep Copy WPF object (e.g. UIElement) ?