Applying a Class inside Javascript

This forum is for all Flare issues related to styles, stylesheets and XML.

Applying a Class inside Javascript

Postby hjohnson on Tue Jun 10, 2008 12:07 am

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
hjohnson
Propeller Head
 
Posts: 12
Joined: Thu Mar 06, 2008 10:15 am

Re: Applying a Class inside Javascript

Postby Dave Lee on Tue Jun 10, 2008 1:16 am

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>");
Dave Lee
Master Propellus Maximus
 
Posts: 5873
Joined: Mon Mar 05, 2007 8:33 am
Location: UK

Re: Applying a Class inside Javascript

Postby hjohnson on Tue Jun 10, 2008 6:21 am

:D It worked! Thanks a bunch, David!

Helen@Block
Helen@Block
hjohnson
Propeller Head
 
Posts: 12
Joined: Thu Mar 06, 2008 10:15 am


Return to Styles, Stylesheets and XML

Who is online

Users browsing this forum: No registered users and 16 guests