# \*\*\*\*ing CDATA section

**URL:** <https://forum.kirupa.com/t/ing-cdata-section/317966>\
**Category:** flash\
**Created:** [January 7, 2011, 3:31am UTC](https://forum.kirupa.com/t/ing-cdata-section/317966 "2011-01-07T03:31:41Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![tibberous](https://avatars.discourse-cdn.com/v4/letter/t/cdc98d/32.png) [@tibberous](https://forum.kirupa.com/u/tibberous)\
**Post date:** [January 7, 2011, 3:31am UTC](https://forum.kirupa.com/t/ing-cdata-section/317966/1 "2011-01-07T03:31:41Z")

</div>

```php

public function shareFacebook(evt:Event = null):void {
  if(ExternalInterface.available) {
    var code:XML = <script>
      <![CDATA[
        function shareFacebook(){
          var d=document
          var f='http://www.facebook.com/share'
          var l=d.location
          var e=encodeURIComponent
          var t=d.title
          var p='.php?src=bm&v=4&i=1277427231&u='+e(l.href)+'&t='+e(t);
          try{if(!/^(.*\.)?facebook\.[^.]*$/.test(l.host))throw(0);share_internal_bookmarklet(p)}catch(z) {a=function() {if (!window.open(f+'r'+p,'sharer','toolbar=0,status=0,resizable=1,width=626,height=436'))l.href=f+p};if (/Firefox/.test(navigator.userAgent))setTimeout(a,0);else{a()}}void(0);
        }
      ]]>
    </script>;
    ExternalInterface.call(code);
  }
}

```

This code create an add-to-facebook link. All I have been trying to do, for the last HOUR AND A \*\*\*\*ING HALF is to get it to go to a url stored in a variable, as opposed to document.location. Problem is, since it is in a CDATA section, it just uses the literal value of whatever I type. I tried converting it from CDATA to a string, but then it threw a javascript error on the page.

Could someone help me fix this, or perhaps point me to a better-written example? I didn’t realize how stupidly this was written until I wasted half my night =/
