Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

i have a tag cloud on my master page. I would like to redirect links of the tags within that tag cloud to another url (script below).

The script runs fine when i test it with the console in firefox but it doesn't work when i put it in the head of my master.

After investigation i have noticed that my script is loaded before a sharepoint webservice /_vti_bin/SocialDataService.asmx/GetAllTagTerms

which could be the reason!

My question is: would it be possible to use jquery to call that webservice and make it work?

$(document).ready(function () {

    var $sel = $("#tagscloud a[href*='tagprofile.aspx?termid=']");

    var rootUrl = $('#ctl00_RootUrlId').val();



    $sel.each(function () {

        var $this = $(this), href = $this.attr('href');

        $this.attr('href', rootUrl + 'Recherche/Pages/Results.aspx?k=SocialTagId%3A%22' + href.slice(href.indexOf('tagprofile.aspx?termid=') + 23) + '%22');

    });

});
share|improve this question

2 Answers 2

here is the answer:

var timer = setInterval(function() { 
        var cloud = $("#tagCloudData"); //need better selector if multiple tag clouds on same page
        if(cloud) {
            clearInterval(timer);
            var $sel = $("#tagscloud a[href*='tagprofile.aspx?termid=']");

    var rootUrl = $('#ctl00_RootUrlId').val();
    $sel.each(function () {
        var $this = $(this), href = $this.attr('href');
        $this.attr('href', rootUrl + 'Recherche/Pages/Results.aspx?k=SocialTagId%3A%22' + href.slice(href.indexOf('tagprofile.aspx?termid=') + 23) + '%22');

    });
        }
    }, 1000)
share|improve this answer

Atos,

Instead of putting this script inside document.ready() handler, can you try calling it with any event handler.

My suggestions would be to put a button and call the script on a button click handler. See if that works.

Sudhir

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.