473,405 Members | 2,282 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,405 software developers and data experts.

text node has text but won't render

This renders in Firefox perfectly well but the text in the red box remains
invisible. The program is a subset of a larger and doesn't do much. but
even after cutting out all the unneccessary stuf, I still can't get it to
work!!

Cheers,

Greg
===================
<xhtml:html xmlns:xhtml="http://www.w3.org/1999/xhtml"
xmlns:svg="http://www.w3.org/2000/svg" >
<xhtml:head>
<xhtml:title>
Intermingled XHTML and SVG
</xhtml:title>
<xhtml:script type="text/javascript" language="JavaScript"><![CDATA[
function gogo(evt){
var targetObj = evt.target; //The object that received the event
var targetDoc = targetObj.ownerDocument; //Owner document var wg =
document.getElementById("SVGroot"); var lg =
document.getElementById("labelz"); //label
labelBox= targetDoc.createElementNS("http://www.w3.org/2000/svg",
"svg:rect"); labelBox.setAttributeNS(null, "id", "label1");
labelBox.setAttributeNS(null, "fill", "red");
labelBox.setAttributeNS(null, "fill-opacity", 1);
labelBox.setAttributeNS(null, "x", 700); labelBox.setAttributeNS(null,
"y", 400); labelBox.setAttributeNS(null, "width", 200);
labelBox.setAttributeNS(null, "height", 20);
labelBox.setAttributeNS(null, "visibility", "visible");
lg.appendChild(labelBox);

labelText = targetDoc.createElementNS("http://www.w3.org/2000/svg",
"svg:text"); labelText.setAttributeNS(null, "id", "labelText1");
labelText.setAttributeNS(null, "x", "5");
labelText.setAttributeNS(null, "y", "5");
labelText.setAttributeNS(null, "style", "font-size:16px;
font-weight:normal; font-family:arial serif; fill:#000000;
fill-opacity:1; opacity:1"); labelBox.appendChild(labelText);

textSpan = targetDoc.createElementNS("http://www.w3.org/2000/svg",
"svg:tspan"); textSpan.setAttributeNS(null, "id", "tspan01");
textSpan.setAttributeNS(null, "x", "5"); textSpan.setAttributeNS(null,
"y", "5"); textSpan.setAttributeNS(null, "style", "font-size:16px;
font-weight:normal; font-family:arial serif; fill:#000000;
fill-opacity:1; opacity:1"); labelText.appendChild(textSpan);

lblTxt = targetDoc.createTextNode("this text has just been created");
textSpan.appendChild(lblTxt);
document.getElementById("tspan01").firstChild.text Content = "this text
has just been updated";
}

function hh(evt){
var thisObj = evt.target;
labelText = thisObj.getAttributeNS(null, "owner");
document.getElementById("tspan01").firstChild.text Content = labelText;

}
]]></xhtml:script>
</xhtml:head>
<xhtml:body >

<svg:svg width="1024px" height="768px" viewbox="0 0 1024 768"
onload="gogo(evt);" id="SVG_diag" xmlns:diag="http://www.diag.com/" >
<svg:g id="SVGroot">

</svg:g>
<svg:g id="labelz">

</svg:g>
</svg:svg>

</xhtml:body>
</xhtml:html>
Jun 22 '06 #1
1 1322


Greg wrote:
This renders in Firefox perfectly well but the text in the red box remains
invisible. The program is a subset of a larger and doesn't do much.


You misunderstand the structure of SVG documents, it is rather flat,
only svg or g elements are container elements of other shapes or text
but your SVG text element does not belong as a child into the SVG rect
element.
So put the SVG text element as a child in an SVG svg element or SVG g
element.

--

Martin Honnen
http://JavaScript.FAQTs.com/
Jun 23 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

15
by: Henning Vestergaard Poulsen | last post by:
Hi, I have a problem that I hope someone can help me with. I'm building a web page with pictures I've taken with my digital camera. I have succeded making a javacript that, when clicking on a...
1
by: Mr. x | last post by:
Hello, Suppose I have a table like this : <table width = "580"> <tr align = "right" width = 760> <td id = "current_page_inner"> <font size="4" color="lightgreen" face="arial"><b><i> abc...
7
by: F. Da Costa | last post by:
Hi, I' looking to retrieve ProdName1 form the <tr> below. <tr id="1-1-1" class="even"> <td> <div class="tier4"> <a href="#" class="leaf"></a> ProdName1 </div>
55
by: Ton den Hartog | last post by:
Stupid basic question but I find it horribly imposible to find the answer elsewhere... :-( I want to have a piece of text in my HTML page and want to be able to change it in a Javascript...
5
by: Steven Berkovitz | last post by:
I am trying (without any luck) to find a way to parse a string and output its processed results. ie: string text = "This is text from a CMS tool <asp:Label runat=\"server\" id=\"test\"...
4
by: pbreah | last post by:
I'm doing a Rich Text Editor (WYSIWYG) in javascript for a game for kids. I'm doing a special case in with every keystroke from A-Z creates a background and foreground color for that letter, witch...
5
by: visu | last post by:
Hi this is a question asked in this group two years back.. No answer for this question till date. now i am in the same situation of the questioner.. to find a solution for this problem. Can any...
4
by: mark4asp | last post by:
I have an element, report which contains tags which have been transformed. E.g. <pis &lt;p&gt <myXml> <report>This text has html tags in it.&lt;p&gt which but <has been changed to &lt;&gt</report>...
2
by: cpup22 | last post by:
I'm new to visual basic but have been playing around with extending the treenode functionalities. I found out how to make it so that after a user clicks on a node in a tree a windows object such as...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.