I have a bookmarklet that sets up a query string for our in-house bug-tracking system. It looks for any text that is selected, if so it sanitizes it and sets it up as a query parameter. Otherwise, it simply navigates to the top-level domain of the intranet site.
javascript:
q = document.getSelection();
u = 'http://my.top.level.domain';
if ( q == '' )
{
q = prompt('Some profoundly insightful text','');
}
if ( q != '' )
{
t = q.toString().replace(/wicked search text/,'sanitized replacement');
q = u + '/results.asp?QueryParam1=qp1&QueryParam2=qp2&QueryParam3=' + escape(t);
}
else
{
q = u;
}
window.location = q;
/* WHAT DO I PUT IN HERE? */;
undefined
What I am trying to do now, is to set the page title to the "sanitized" text. For this, I have tried various permutations of the following:
window.document.title=t;
document.onload=function()
{
document.title=t;
};
I have swapped the order, put one before/after the other and so on. At times, I see the title briefly set to the sanitized replacement text, soon to be replaced by whatever is fetched from our intranet site. At other times, it has no effect whatsoever.
Would appreciate if anyone could help with "WHAT DO I PUT IN HERE?" portion of the bookmarklet so that the title of the 'query result' page would be set based on the 'sanitized replacement text'.
Thank you.