| In the JavaScript function KeyWordInit(), we collect the A tags as they exist prior to link creation into an array. If our replacement process happens to alter a link, we'll use this array to reset the links in the page after the process has completed. We utilize IE behaviors to support normal events over tags such as the BOLD tag we've used here. By attaching behavior events to the style, we can trigger JavaScript functionality not normally available. |
| While testing the code, I noticed that on larger pages, the collapse(true) didn't always reset the text range to the beginning again after processing several keywords. For this reason, you'll see what appears to be an unnecessary recreation of the text range on the body object. Please review the comments in the JavaScript file for details of how this keyword conversion actually works. |
| Please take a moment to rate this article. Rate Article (opens in separate window). |
|
| Sample HTML Page |
<form> id=frmSubmit name=frmSubmit>
</form>
|
| Keywordpro.js JavaScript File |
function KeyWordInit()
{
// Create an XML document object reference to our XML data island
var oXMLDoc = window.document.all("xmlkeywords");
// Create an XML document list of all keywords
var oXMLList = oXMLDoc.selectNodes("//KEYWORDS/KEYWORD");
// How many keywords do we have?
var nTot = oXMLList.length;
var sKeyURL='';
var sKeyPhrase='';
// This array stores the actual .href values of existing links.
var oLinks = new Array();
// This array stores the contents between the tags
var oLinksHTML = new Array();
var nLinks = document.all.tags('A').length;
// Store our current links in their proper arrays.
for (i=0;i' + oRange.text + '');
oRange.collapse(false);
}
catch (e) { oRange.collapse(false); }
}
}
// go through all of the links again and replace them with their original values just in case our processing
// pasted invalid html in them.
for (i=0;i |
| Keywordpro.xml Data Island File |
http://www.eggheadcafe.com/keywordpromo.asp
http://www.eggheadcafe.com/keywordpromo.asp
http://www.eggheadcafe.com/keywordpromo.asp
http://www.eggheadcafe.com/keywordpromo.asp
http://www.eggheadcafe.com/keywordpromo.asp
|
| Keywordpro.htc Behavior File |
|