Welcome
Login  |  Register
Tuesday, January 06, 2009
  Search
You are here:Knowledge Base
 
 
 

 Please Register or login to view our private forums, it is free!!

Subject: java-based hyperlink by keyword
Prev Next
You are not authorized to post a reply.

Author Messages
hostUser is Offline
Posts:90

03/31/2007 12:39 PM  

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>
          
xml stuff
XML101.com
</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




   

You are not authorized to post a reply.
Forums > Knowledge Base Systems > Windows > java-based hyperlink by keyword



ActiveForums 3.7
 
Copyright 2006-7 Vigilant Support