+ Start a Discussion
toddnewmantoddnewman 

javascript gets mangled

I have some Javascript in a visualforce page that looks like this.

 

 ...

jQuery('#previewOrderPane')

   .append('<table id="previewOrderTable"></table>');

...


if (previewUrl != "") {

        previewUrl = '<a href="' + previewUrl + '" target="_blank">Preview...</a>';

}

...

 

But in a browser, this is what I see in the source.

 

 

...
jQuery('#previewOrderPane')
  .append('<table></table>');
...

   if (previewUrl != "") {
     + previewUrl + '">Preview...</a>';
   }
...
Of course that is a syntax error.  If I remove the function containing this block of code, everything is great.  As I add the function back piece by piece it looks good (minus that ID on the table).  But eventually it gets mangled.  Sometimes sooner but always by the time I get to that previewUrl string concatenation.

 

 

Not sure if this is related, but if I edit the page in the Salesforce setup area (rather than Eclipse), I always get this warning:

 

Warning: The element type "param" should be terminated by the matching end-tag "</param>" at line 82

 

Always at line 82.  I don't have a param element on the page.  I can strip the page all the way down to this:

 

<apex:page controller="DirectMailOrderController" title="Marketing Supplies Order" tabStyle="Case" id="mainPage">


<h1>Marketing Supplies Order</h1>

</apex:page>

 

And I still get the same warning thus telling me that it's not invalid xhtml that is the problem.

 

Best Answer chosen by Admin (Salesforce Developers) 
toddnewmantoddnewman

I think I've solved it.

 

I changed the version on the Visualforce page from 16.0 to 20.0 and so far so good.

 

I'm not sure why I even thought to do that.  Probably because the mention of the xhtml parser in the linked thread.