PDA

View Full Version : Issue in assigning html that has javascript to an Ext Window



AmeetC
16 Mar 2015, 10:55 PM
I have Ext.Window in which I load the html response from a service. The html response has javascript (two functions) in the <head> section and anchor elements in <body> have onclick event calls to these functions.
I assign this complete html response to Ext Window (code is given below). The response in shown fine in the Ext Window when app runs but when clicking on anchors, the javascript code is not found. (functions are undefined as I see in browser's debug tools), even tough I have verified that the response does have the functions in the <head> section.
Please help me how I can switch on javascript code in Ext Window, when I assign the html to it as follows.

var responseHtml;
... // I get response html from a service
this.validationResultWindow = new Ext.Window({
title: OpenLayers.i18n('validationResultWindowTitle'),
layout: 'fit',
autoScroll: true,
closeAction: 'destroy',
iconCls: 'linkIcon',
modal: false
//style: {'z-index':'22000'}
});
this.validationResultWindow.html = responseHtml;
this.validationResultWindow.show();

The htmlResponse is as follows
<html>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<head>
<script type="text/javascript">
function getHtml(URL) { ...}
function getXML(URL) {...}
</script>
</head>
<body>
<pre>
<a href="#" onclick='getXML("https://localhost:8080/servFront?version=1.0")'>View - XML</a>
<a href="#" id="viewHtml" onclick='getHtml("https://localhost:8080/servFront?version=5.0' >View - HTML</a>
</pre>
</body>
</html>

Gary Schlosberg
31 Mar 2015, 4:20 AM
I'm not sure this will work because you can only have one <head> section in an HTML document. Guessing this second one is not being evaluated properly because of that. An iframe might work since it runs the content as its own page.