+1-888-365-2779
Try Now
More in this section

Forums / Bugs & Issues / Need a way to insert javascript into a page

Need a way to insert javascript into a page

3 posts, 0 answered
  1. viscious
    viscious avatar
    31 posts
    Registered:
    10 Aug 2006
    25 Jan 2008
    Link to this post
    Hello.  I have an advertisement system, that generates javascript snipets.  These snipits need to be placed into the page at certain places.

    I was hoping that I could just a use a RadEditor to paste the javascript into code view.  Unfortunately the editor stripped the javascript. 

    Then I found a property for the editor for AllowScripts, and I set that to true.

    Now it almost works, but inside the javascript there are parts where there is some code like document.write('<s'+'cript lang' + 'uage="jav' + 'ascript"

    Unfortunatly the editor is changing the less than sign to an lt; entity.

    I also tried creating a custom control and a webuittypeEditor<string> to handle the insertion of this code.   But that didnt work either.

    Any suggestions?
  2. viscious
    viscious avatar
    31 posts
    Registered:
    10 Aug 2006
    25 Jan 2008
    Link to this post
    In case it matter here is a full code snipet that I need to place, as an example

    <!-- Begin -  Site: OystersAndChocolate Zone: Test Zone -->
    <script language="javascript"  type="text/javascript">
    <!--
    var browName = navigator.appName;
    var SiteID = 1;
    var ZoneID = 1;
    var browDateTime = (new Date()).getTime();
    if (browName=='Netscape')
    {
    document.write('<s'+'cript lang' + 'uage="jav' + 'ascript" src="http://localhost:13572/banmanprosql8/a.aspx?ZoneID=' + ZoneID + '&amp;Task=Get&amp;IFR=False&amp;Browser=NETSCAPE4&amp;PageID=16347&amp;SiteID=' + SiteID + '&amp;Random=' + browDateTime  + '">'); document.write('</'+'scr'+'ipt>');
    }
    if (browName!='Netscape')
    {
    document.write('<s'+'cript lang' + 'uage="jav' + 'ascript" src="http://localhost:13572/banmanprosql8/a.aspx?ZoneID=' + ZoneID + '&amp;Task=Get&amp;IFR=False&amp;PageID=16347&amp;SiteID=' + SiteID + '&amp;Random=' + browDateTime  + '">'); document.write('</'+'scr'+'ipt>');
    }
    // -->
    </script>
    <noscript>
        <a href="http://localhost:13572/banmanprosql8/a.aspx?ZoneID=1&amp;Task=Click&amp;Mode=HTML&amp;SiteID=1&amp;PageID=16347" target="_blank">
        <img src="http://localhost:13572/banmanprosql8/a.aspx?ZoneID=1&amp;Task=Get&amp;Mode=HTML&amp;SiteID=1&amp;PageID=16347" width="265" height="97" border="0"  alt=""></a>
    </noscript>


  3. Vassil Daskalov
    Vassil Daskalov avatar
    261 posts
    Registered:
    18 May 2013
    28 Jan 2008
    Link to this post
    Hello Eric,

    Try to wrap your code inside CDATA section "<![CDATA[" and end with "]]>". The code which is inside this section is ignored by the xml parsers. Hope it helps. At least it does here.
    Let us know about any further help you might need.

    Best wishes,
    Vassil Daskalov
    the Telerik team

    Instantly find answers to your questions at the new Telerik Support Center
Register for webinar
3 posts, 0 answered