XML / DOM Script Question

This forum is for all Flare issues related to the HTML5, WebHelp, WebHelp Plus, and Adobe Air Targets
Post Reply
Alec_McTurk
Jr. Propeller Head
Posts: 5
Joined: Thu Jun 26, 2008 7:26 am

XML / DOM Script Question

Post by Alec_McTurk »

I'd like to put client-side Javascript into my masterpage that can read the concept term from the current page, and assign the value to a variable.

i.e., if within my document I have:

<MadCap:concept term="Scripting" />

I want to be able to do something like:

<script language = Javascript>
var currentConcept = document.getElementsByTagName("MadCap:concept").something?? - what do I need here??

// This should display the word "Scripting":
alert(currentConcept);
</script>

Thanks for any pointers.
GregStenhouse
Sr. Propeller Head
Posts: 330
Joined: Tue May 13, 2008 3:27 pm
Location: Christchurch, New Zealand

Re: XML / DOM Script Question

Post by GregStenhouse »

Here is something I use to capture the breadcrumbs in a variable, maybe it will help? I think from memory I really struggled to get anything with <madcap: > into a variable and had to wrap into a <div>

On my breadcrumbs masterpage I have:

Code: Select all

 <div id="bcrumbs">
<MadCap:breadcrumbsProxy class="Breadcrumb" />
</div>
And then in a separate script I use

Code: Select all

var textNode = document.getElementById("bcrumbs");
var textValue1 = textNode.innerHTML;
var textValue2 = textValue1.replace(/<[^>]*>/g,"");
var textValue3 = textValue2.replace(/>/g,">");
Cheers
Greg
Alec_McTurk
Jr. Propeller Head
Posts: 5
Joined: Thu Jun 26, 2008 7:26 am

Re: XML / DOM Script Question

Post by Alec_McTurk »

Greg, thanks - this is a good idea. However I don't think it will work for me because I can't put a div in the masterpage around where my Concept tag will be in the topic (unlike your breadcrumbs example which is in an identifiable spot in the master page)
Post Reply