# XML Cdata and Java Script working together?

**URL:** <https://forum.kirupa.com/t/xml-cdata-and-java-script-working-together/263232>\
**Category:** Uncategorized\
**Created:** [June 13, 2008, 3:45pm UTC](https://forum.kirupa.com/t/xml-cdata-and-java-script-working-together/263232 "2008-06-13T15:45:50Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![ponyack](https://avatars.discourse-cdn.com/v4/letter/p/76d3ee/32.png) [@ponyack](https://forum.kirupa.com/u/ponyack)\
**Post date:** [June 13, 2008, 3:45pm UTC](https://forum.kirupa.com/t/xml-cdata-and-java-script-working-together/263232/1 "2008-06-13T15:45:50Z")

</div>

Hi,

I have a gallery that when the image is clicked a window pops up with a description.

the description is in the xml file

but if i have a special character ( ’ apostrophe )i n the xml file the pop up will not work open

I tried cdata but not sure how to implement that.

The gallery was built in flash and but the pop up is html

here is the java is sits in an html page where the flash is embedded

do i need to tell the javascript that i am using cdata?

any help would be great.

Thanks

Ponyack

```auto
<script language="JavaScript" type="text/javascript">
            function popUp(target, w, h, path, caption, description){
                var scrW = screen.width;
                var scrH = screen.height;

                var x = Math.floor((scrW - w)/2);
                var y = Math.floor((scrH - h)/2);

                var uri = target + "?path=" + path + "&caption=" + caption + "&description=" + description;
                wnd = window.open(uri, 'galleryImage', 'height=' + h + ', width=' + w + ', left=' + x + ', top=' + y + ', toolbar=no, location=no, directories=yes, status=no, menubar=yes, scrollbars=yes, resizable=yes');
            }

            function cleanPopUp(w, h, path){
                var scrW = screen.width;
                var scrH = screen.height;

                var x = Math.floor((scrW - w)/2);
                var y = Math.floor((scrH - h)/2);

                wnd = window.open('', 'galleryImage', 'height=' + h + ', width=' + w + ', left=' + x + ', top=' + y + ', toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=yes, resizable=no');
                wnd.document.write('<body topmargin=0 bottommargin=0 rightmargin=0 leftmargin=0>');
                wnd.document.write('<img src="' + path + '" />');
                wnd.document.write('</body>');
            }
        </script>

```

---

<div class="post-metadata">

**Author:** ![sekasi](https://avatars.discourse-cdn.com/v4/letter/s/5f8ce5/32.png) [@sekasi](https://forum.kirupa.com/u/sekasi)\
**Post date:** [June 13, 2008, 4:06pm UTC](https://forum.kirupa.com/t/xml-cdata-and-java-script-working-together/263232/2 "2008-06-13T16:06:17Z")

</div>

Escape characters like apostrophies, quotes

’ becomes ’

---

<div class="post-metadata">

**Author:** ![ponyack](https://avatars.discourse-cdn.com/v4/letter/p/76d3ee/32.png) [@ponyack](https://forum.kirupa.com/u/ponyack)\
**Post date:** [June 13, 2008, 6:06pm UTC](https://forum.kirupa.com/t/xml-cdata-and-java-script-working-together/263232/3 "2008-06-13T18:06:32Z")

</div>

Thanks for the reply.

So how can I get the ’ apostrophe to parse?

I tried using the special character ' but the popup hmtl window would not work

I apologize, but I am new to most of this so I am learning as I go.

Could you show an example or link me to an explanation.

The next post is the popup html code

Thanks

Ponyack

---

<div class="post-metadata">

**Author:** ![ponyack](https://avatars.discourse-cdn.com/v4/letter/p/76d3ee/32.png) [@ponyack](https://forum.kirupa.com/u/ponyack)\
**Post date:** [June 13, 2008, 6:10pm UTC](https://forum.kirupa.com/t/xml-cdata-and-java-script-working-together/263232/4 "2008-06-13T18:10:35Z")

</div>

pop up html code

```auto
    <head>
        <script language="JavaScript" type="text/javascript">
            function getVariable(varName){
                var arg = document.location.search.substring(1).split('&');
                var variable = "";
                var i;
                for(i=0; i<arg.length; i++){
                    if(arg*.split('=')[0] == varName){
                        if(arg*.split('=').length>1){
                            variable = unescape(arg*.split('=')[1]);
                        }
                        return variable;
                    }
                }
                return "";
            }
        </script>
          <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
          <style type="text/css">
              TD.image{
                  text-align: center;
                  padding: 0px;
              }

            TD.caption{
                color: #ffff33;
                font-size:11pt;
                font-family:Verdana;
                font-weight:bold;
            }

            TD.description {
                color:#ffffff;
                font-size:10pt;
                font-family:Verdana;
                
            }
        </style>
     </head>
    <body bgcolor=#666666 topmargin=0 leftmargin=0 marginheight=0 marginwidth=0 >
        <script language="JavaScript" type="text/javascript">
            var caption = getVariable("caption");
            var imgsrc = getVariable("path");
            var description = getVariable("description");

            document.write('<table border=0 cellpadding=5 cellspacing=0 width=100%>');
            document.write('<tr><td class="image"><img src=' + imgsrc + '></td></tr>');
            document.write('<tr><td class="caption">' + caption + '</td></tr>');
            document.write('<tr><td class="description">' + description + '</td></tr>');
            document.write('</table>');
        </script>
    </body>
</html>

```
