如何分配scriplet<%>值为javascript变量?

时间:2011-01-26 12:35:05

标签: jsp

<script type="text/javascript">
var sBasePath = document.location.href.substring(0,document.location.href.lastIndexOf('_samples')) ;

var oFCKeditor = new FCKeditor( 'FCKeditor1' ) ;
oFCKeditor.BasePath = sBasePath ;
oFCKeditor.Height = 300 ;
//documents.write(test);
**oFCKeditor.Value = '';//i want to assign <%=strPageContent%> here but its not working....**

oFCKeditor.Create() ;//-->
</script>

1 个答案:

答案 0 :(得分:2)

如果您有一个名为strPageContent的变量,则以下内容有效:

oFCKeditor.Value = '<%=strPageContent%>';

如果您将它作为请求属性(例如在servlet中设置为request.setAttribute(..)),而不是作为变量,那么:

oFCKeditor.Value = '${strPageContent}';