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 biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Javascript in XSLT Problem.

Status
Not open for further replies.

beefeater267

Programmer
Apr 6, 2005
79
Hi,

I have an XSLT where i am generating some JS statements. However, am having problems b/c of the quotes.

Can anyone help. For example, I have:

<SCRIPT>
var ifr = document.frames('IF<xsl:value-of select="TITLE" />');

ifr.document.write("<BODY BORDER=\'0\'>")
ifr.document.write('</BODY>')
ifr.document.close()
</SCRIPT>

The error occurs on the "<BODY>" line.

how can i perform this type of syntax?
 
Are you sure it's not the < and >

replace all < with &lt;
and all > with &gt;

As far as the Body goes... you don't need escapes for ' if your string is enclosed with "
...
ifr.document.write("<BODY BORDER='0'>")

try this:
Code:
<SCRIPT>
var ifr = document.frames('IF&lt;xsl:value-of select="TITLE" /&gt;'); 

ifr.document.write("&lt;BODY BORDER='0'&gt;")
ifr.document.write('&lt;/BODY&gt;')
ifr.document.close()            
</SCRIPT>

Visit My Site
PROGRAMMER: (n) Red-eyed, mumbling mammal capable of conversing with inanimate objects.
 
still get JS errors when I try your code. Any other suggestions?
 
I tried:

<SCRIPT>
var ifr = document.frames('IF<xsl:value-of select="TITLE" />');
ifr.document.write("&lt;BODY bgcolor='red'&gt;")
ifr.document.write('&lt;/BODY&gt;')
ifr.document.close()
</SCRIPT>

However, the <BODY> tags are not rendered, but rather put as text in my IFRAME.

PLEASE HELP!
 
And this is inside an XSLT?

any case... did you try just:
Code:
<SCRIPT>
var ifr = document.frames('IF<xsl:value-of select="TITLE" />'); 
ifr.document.write("<BODY BORDER='0'>")
ifr.document.write('</BODY>')
ifr.document.close()                
</SCRIPT>

Or...
Code:
<SCRIPT>
[COLOR=red]<![CDATA[[/color]
var ifr = document.frames('IF<xsl:value-of select="TITLE" />'); 
ifr.document.write("<BODY BORDER='0'>")
ifr.document.write('</BODY>')
ifr.document.close()
[COLOR=red]]]>[/color]
</SCRIPT>



Visit My Site
PROGRAMMER: (n) Red-eyed, mumbling mammal capable of conversing with inanimate objects.
 
Ohhhh... and you might also need the ;'s at the end of every line...
Code:
<SCRIPT>
<![CDATA[
var ifr = document.frames('IF<xsl:value-of select="TITLE" />'); 
ifr.document.write("<BODY BORDER='0'>")[COLOR=red];[/color]
ifr.document.write('</BODY>')[COLOR=red];[/color]
ifr.document.close()[COLOR=red];[/color]
]]>
</SCRIPT>

Visit My Site
PROGRAMMER: (n) Red-eyed, mumbling mammal capable of conversing with inanimate objects.
 
i will try your CDATA example. what exactly does that syntax mean ([CDATA])?

I'm new to XML
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top