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.
XML / DOM Script Question
-
- Jr. Propeller Head
- Posts: 5
- Joined: Thu Jun 26, 2008 7:26 am
-
- Sr. Propeller Head
- Posts: 330
- Joined: Tue May 13, 2008 3:27 pm
- Location: Christchurch, New Zealand
Re: XML / DOM Script Question
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:
And then in a separate script I use
Cheers
Greg
On my breadcrumbs masterpage I have:
Code: Select all
<div id="bcrumbs">
<MadCap:breadcrumbsProxy class="Breadcrumb" />
</div>
Code: Select all
var textNode = document.getElementById("bcrumbs");
var textValue1 = textNode.innerHTML;
var textValue2 = textValue1.replace(/<[^>]*>/g,"");
var textValue3 = textValue2.replace(/>/g,">");
Greg
-
- Jr. Propeller Head
- Posts: 5
- Joined: Thu Jun 26, 2008 7:26 am
Re: XML / DOM Script Question
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)