Applying a Class inside Javascript

This forum is for all Flare issues related to styles, stylesheets and XML.
Post Reply
hjohnson
Propeller Head
Posts: 12
Joined: Thu Mar 06, 2008 10:15 am

Applying a Class inside Javascript

Post by hjohnson »

Hello -

I have been trying to encorporate the script example in the KB document GEN1013-F Adding an Email Link to Every Page in your Output into my new Flare HTML Help template, and discovered this issue with the last line of the script:

Code: Select all

document.write ("<a href="+ docfdbk_a + docfdbk_b + docfdbk_c + docfdbk_d + docfdbk_e + docfdbk_f + docfdbk_g + document.title +">Send us feedback!</a>");
This script is included in a paragraph with the font size 8pt. However, the <a> tag in the script wants to use the settings I have for <a> in my style sheet - which is 10pt. So in the finished product, the link that opens the feedback email is 10pt and stands out from surrounding text.

I made a class of <a> called a.script with 8pt font. Then, adding [class="Script"], I changed the script to

Code: Select all

document.write ("<a href="+ docfdbk_a + docfdbk_b + docfdbk_c + docfdbk_d + docfdbk_e + docfdbk_f + docfdbk_g + document.title +" class="Script">Send us feedback!</a>"); 
, and got the attached error when I previewed the topic:
error.PNG
I'm stuck. :? Suggestions???

Thanks - Helen@Block
You do not have the required permissions to view the files attached to this post.
Helen@Block
NorthEast
Master Propellus Maximus
Posts: 6359
Joined: Mon Mar 05, 2007 8:33 am

Re: Applying a Class inside Javascript

Post by NorthEast »

Yep, it's your quotes in the section +" class="Script">Send us feedback!</a>"

In the javascript, you're using quotes within quotes, so you need to tell it that the quotes around "Script" are part of the text.
To do this use a \ character before the quote, e.g.

Code: Select all

document.write ("<a href="+ docfdbk_a + docfdbk_b + docfdbk_c + docfdbk_d + docfdbk_e + docfdbk_f + docfdbk_g + document.title +" class=\"Script\">Send us feedback!</a>");
hjohnson
Propeller Head
Posts: 12
Joined: Thu Mar 06, 2008 10:15 am

Re: Applying a Class inside Javascript

Post by hjohnson »

:D It worked! Thanks a bunch, David!

Helen@Block
Helen@Block
Post Reply