+ Start a Discussion
Edwin VijayEdwin Vijay 

document.write causes the UI to look weird

Hi All,


I have a custom application which has been developed using Visualforce. Everything works fine with the old User Interface theme.


I turned on the new User Interface theme, and the UI looks too bad. Luckily, i was able to narrow down on one particular line which has been causing this problem.


We have a javascript function which is used to track site visitors. This function has the following lines


<script language="JavaScript" type="text/javascript">
var s_code=s.t();if(s_code)document.write(s_code)

 The colored part is a valid single line comment format in javascript, but not in visualforce. Hence, i had to remove the colored part and the function works as expected.


With the new UI, the document.write(s_code) statement causes my visualforce page to extend beyond the pageblock placeholder.


A sample of the image is below. Any suggestions highly appreciated.












It depends what it writes and where it writes it too, do you have an example?


Do you want to include the comment syntax? There is a way.



Edwin VijayEdwin Vijay

Hi Wez,


This javascript has been provided by a third party company. I have no idea what it writes, i also tried to use alert() to display what it writes.. But it shows an empty box. I have included this javascript right after my apex:page tag.....


Good to know that there is a way to use comments. Please let me know how...


Thanks for your response...





My guess is that it's inserting something into your DOM that throws your formatting out, but it's difficult to know how to fix it without knowing more. To see how to comment in a VF page check out this thread: