Hi
I've been trying to create a plugin for the FCKEditor to automatically add tracking for Google Analytics for each link added. It works ok in Firefox as it uses the InsertHTML command but in IE8 I get the good old "Object expected" error which fails on the following function - SetAttribute. The updated code is below:
Has anyone tried to do anything similar, I've checked the forums to no avail. Any help or advice appreciated!
Cheers
Shaun
I've been trying to create a plugin for the FCKEditor to automatically add tracking for Google Analytics for each link added. It works ok in Firefox as it uses the InsertHTML command but in IE8 I get the good old "Object expected" error which fails on the following function - SetAttribute. The updated code is below:
var oEditor = window.parent.InnerDialogLoaded() ; var FCKLang = oEditor.FCKLang ; var FCKSelectlink = oEditor.FCKSelectlink ; var FCK = oEditor.FCK ; window.parent.SetOkButton( true ) ; Ok =function() { if(typeof(document.forms.frmLinks.theLinks) != 'undefined'){ var theChoice = -1; if(document.frmLinks.theLinks.length == undefined){ theChoice = 0; theLink=document.forms.frmLinks.theLinks.value.split("^") } else { for (counter = 0; counter < document.frmLinks.theLinks.length; counter++) { if (document.frmLinks.theLinks[counter].checked) { theChoice = counter; var theLink=document.forms.frmLinks.theLinks[theChoice].value.split("^"); } } } if(theChoice != -1){ if(document.all) { var onclick; var myDownload='TempValue'; mySelection = FCK.EditorDocument.selection; if(mySelection.type=='Text'){ oLink = oEditor.FCK.CreateLink(theLink[0]) ; onclick = "javascript: pageTracker._trackPageview(\'/downloads/'+myDownload+'\');"; onclick = encodeURIComponent( " onclick=\"" + onclick + "\"" ) ; SetAttribute( oLink, 'onclick', onclick ) ; } else { FCK.Focus() var myRange=mySelection.createRange(); myRange.text= theLink[1]; myRange.moveStart('character', -theLink[1].length); myRange.select(); oLink = oEditor.FCK.CreateLink(theLink[0]) ; onclick = "javascript: pageTracker._trackPageview(\'/downloads/'+myDownload+'\');"; onclick = encodeURIComponent( " onclick=\"" + onclick + "\"" ) ; SetAttribute( oLink, 'onclick', onclick ) ; } } else { //mySelection = FCK.EditorDocument.getSelection(); mySelection = FCK.EditorWindow.getSelection(); if(mySelection.length > 0 ){ oLink = oEditor.FCK.CreateLink(theLink[0]) ; onclick = "javascript: pageTracker._trackPageview(\'/downloads/'+myDownload+'\');"; onclick = encodeURIComponent( " onclick=\"" + onclick + "\"" ) ; SetAttribute( oLink, 'onclick', onclick ) ; } else { oEditor.FCK.InsertHtml('<a href="' + theLink[0] + '" onclick="javascript: pageTracker._trackPageview(\'/downloads/'+myDownload+'\');">' + theLink[1] + '</a>') ; } } window.parent.Cancel() ; } } else { window.parent.Cancel() ; } }
Has anyone tried to do anything similar, I've checked the forums to no avail. Any help or advice appreciated!
Cheers
Shaun