Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

Cabbit

macrumors 68020
Original poster
Jan 30, 2006
2,128
1
Scotland
how do i get it so that my script wont error out when the element editor isnt present?

Code:
<script type="text/javascript">
			window.onload = function()
				{
				var oFCKeditor = new FCKeditor( 'editor' ) ;
				oFCKeditor.BasePath = "../editor/" ;
				oFCKeditor.ReplaceTextarea() ;
				}
		</script>
 
This code will assume 'editor' is an id attribute for a tag in the document. You can add an else statement if you have something else to do if it's not present.
Code:
window.onload = function()
{
  if (document.getElementById('editor')) {
    var oFCKeditor = new FCKeditor( 'editor' ) ;
    oFCKeditor.BasePath = "../editor/" ;
    oFCKeditor.ReplaceTextarea() ;
  }
}
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.