A couple of weeks back I was working with some colleagues, designing page layouts and master pages, and having lots of fun implementing some cool designs... One guy asked about embedding JavaScript into a page and I suggested he use the content editor Web part (CEWP, source editor). At the time he was under the impression you could embed JavaScript into the out-of-the-box (OOTB) HTML/rich text page content editor but instead found that the editor stripped any code entered into HTML view. So, I suggested the alternative may be to try the Telerik r.a.d. editor for MOSS (similar functionality to the OOTB HTML editor but more suited to cross-browser functionality). I decided to try this myself and found some interesting results.
Firstly, I confirmed that the OOTB HTML editor does indeed strip any scripting out – you can paste code into the HTML view of the editor but as soon as you save it any code gets stripped out, but basic HTML formatting gets left behind.

My sample piece of JavaScript is shown in the following figure. You’ll also note that the sample includes <form> tags.

I’d forgotten about earlier issues I’d experienced with <form> tags in SharePoint and next tried pasting my code into the Telerik r.a.d. editor for MOSS Web part, only to meet the dreaded ‘error – return to site’ page. My only escape was to kill the Web part by going into the Web part maintenance page and closing it.
Next, I copied my code into the CEWP, source editor (which I’d always used for adding script to individual pages) and BINGO…that’s when I remembered the issue with <form> tags – see below. I also remembered having had this issue in SPS2003.

Once I stripped out my <form> tag, the code was also successfully placed in the Telerik r.a.d. editor.

So, a couple of options for including JavaScript on SharePoint pages – (the usual suspect) CEWP, and Telerik r.a.d. editor for MOSS. Just watch for <form> tags.