Search code examples
javascriptencodingsharepoint-2010hyperlinkapostrophe

Javascript link in aspx page within a SharePoint frame replaces apostrophes to #39 element


I have problem with SharePoint encoding the javascript link, that normally renders like href="javascript:Function('url');" but in Sharepoint like href="javascript:Function(& #39;url& #39;)" wich of course does not work.

What do I need to do?

I need to be able to use my user control as stand alone as well as linked into a sharepoint page, right!?


Solution

  • Where are you inserting the code? Within a web part, a custom control, etc?

    If you are trying to use the Content Editor web part I did notice some differences with it in 2010. When trying to use items that require javascript I just created a .txt file that resides in the SiteAssets. The file contains all the HTML/JS that I would normally add to the web part. Then point/link the Content Editor web part at that file.

    This seemed to fix some issues I was having. Could work for you.