This is a migrated thread and some comments may be shown as answers.

[Solved] script error when embedding in html

1 Answer 110 Views
Editor
This is a migrated thread and some comments may be shown as answers.
Marty
Top achievements
Rank 1
Marty asked on 18 Jun 2009, 03:49 PM
Hello.

We're using the RadEditor with a custom button that embeds the following markup in the HTML viewer:
<div id="mg_001"
  
<script type="text/javascript">swfobject.embedSWF("/upload/mediagallery/viewers/slideshow.swf", "mg_001", "452", "327", "8.0.0", "/upload/flash/expressInstall.swf", { gallery: "10", album: "1", item: "2"}, { menu: "false", wmode: "transparent" }, {});</script> 
</div> 
 

The insert works fine.  However, after inserting, when you select the HTML view, it looks like it tries to execute the script tags in the code that we embedded... it fails because it cannot find the externally referenced js file that defines the swfobject which in turn leaves that variable set to null.  Including the external JS file that houses the script on the page that the editor is on makes no difference, nor does embedding the external reference in the html content above.  The quircky part of this, is that if you LOAD the editor with this code already inserted, and switch to the HTML view, the issue does not occur... it's only when adding it to an existing editor.  I hope this makes sense.

We need to be able to use the script tags in this code.  We have AllowScripts and EnableEmbeddedScripts both set to true, with again no impact on this issue.  This is using Q1 controls, with the latest SP, windows vista .net 3.5.

Is there a way to stop the editor from trying to execute the script when swithing into the HTML view?

Thanks,
Marty

1 Answer, 1 is accepted

Sort by
0
Lini
Telerik team
answered on 22 Jun 2009, 11:40 AM
Hi Marty,

The default editor behavior is to stop all scripts from executing. This is done via a content filter called EncodeScripts. This filter removes the <script> tags when you put the editor in Design mode, which will prevent them from running and potentially throwing errors. If the script is being executed, then this filter must be disabled in your editor configuration. You need to enable it to fix the reference error. You can enable the filter from your page code:

protected void Page_Load(object sender, EventArgs e) 
    RadEditor1.EnableFilter(EditorFilters.EncodeScripts); 

All the best,
Lini
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
Tags
Editor
Asked by
Marty
Top achievements
Rank 1
Answers by
Lini
Telerik team
Share this question
or