Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

XML / XSL / Javascript... 1

Status
Not open for further replies.

rjonesX

Technical User
Jun 18, 2001
56
US
Im having difficult w/ XSL and Javascript.

Basically, i have an xsl document that includes javascript in the header (generated by dreamweaver], for the purposes of showing, i have replaced the < with [

HTML:
[head]
[script language=&quot;javascript']
[!--
function MM_findObj(n, d) { //v4.0
  var p,i,x;  if(!d) d=document; if((p=n.indexOf(&quot;?&quot;))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && document.getElementById) x=document.getElementById(n); return x;
}

function MM_changeProp(objName,x,theProp,theValue) { //v3.0
  var obj = MM_findObj(objName);
  if (obj && (theProp.indexOf(&quot;style.&quot;)==-1 || obj.style)) eval(&quot;obj.&quot;+theProp+&quot;='&quot;+theValue+&quot;'&quot;);
}
//--]
[/script]

[/head]
[body]
.....



anyway, when that code, or any javascript for that matter, is included in the document header, the xsl page does not work at all. If removed, it works. What gives?


russ
 
Hello,
See an working example:
<xsl:stylesheet version=&quot;1.0&quot; xmlns:xsl=&quot; <xsl:template match=&quot;/&quot;>
<html>
<head><script language=&quot;JavaScript&quot;>
<xsl:comment><![CDATA[
function showme(){
alert(&quot;This comes from JS&quot;);
}
]]></xsl:comment>
</script>

</head>
<body>
<a href=&quot;#&quot; onclick=&quot;showme()&quot;>Show me</a>
</body>
</html>
</xsl:template>
</xsl:stylesheet>

It can be used with any xml file for testing.
Success!
 
A follow up question on this, I've got some javascript which is defined as a CDATA attribute, but my problem is I include markup in my JavaScript. In turn this markup is converted to text (ie <form> is converted to <form> etc.) is there a way to pass the markup to the browser?

Code:
<![CDATA[
	letterList = new List(false, width, height, &quot;#DDDDDD&quot;);
		letterList.addItem('<form name=&quot;Letters1&quot;><input type=&quot;checkbox&quot;>Bonus History</input></form>');
		letterList.addItem('<form name=&quot;Letters2&quot;><input type=&quot;checkbox&quot;>DD Mandate</input></form>');
		letterList.addItem('<form name=&quot;Letters3&quot;><input type=&quot;checkbox&quot;>Form Of Indemnity</input></form>');
		letterList.addItem('<form name=&quot;Letters4&quot;><input type=&quot;checkbox&quot;>Fund Switch</input></form>');
		myList.addList(letterList,&quot;Letters&quot;)
]]>
 
that the html mark up in there is each separated by the cdata section

<!CDATA[
javascript.code('
]]>html markup
<!CDATA['more.code
]]>

like that.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top