473,397 Members | 1,960 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,397 software developers and data experts.

Javascript displays Chinese writing on svg file

Hello:

I failed to display a Chinese character with javascript code in
following svg page:

http://www.pinyinology.com/test/hanzi2.svg

I guess that something is missing or wrong in the javascript code.
There is only one line of instruction in the javascript section, and
only one symbol to be displayed. But I simply cannot do it. The code
is as follows:

<?xml version="1.0" standalone="no"?>

<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN"
"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">

<svg onload="chinText()" width="100%" height="100%" version="1.1"
xmlns="http://www.w3.org/2000/svg">

<script type='text/ecmascript'>
<![CDATA[
function chinText()
{
document.getElementById("moon").innerHTML ="\u6708"; //javascript
command
}
]]>
</script>

<text id="moon" x="128" y="150" style="fill:blue; font-family:times;
font-size:150%; font-weight:700; stroke:none;">Character fails to
appear here.</text//svg tags for the character.

<text id="moon" x="128" y="200" style="fill:red; font-family:times;
font-size:150%; font-weight:600; stroke:none;">This character will
appear at 4 locations in this page.</text>
</svg>

I wish someone could help me.

javascript can display chinese ideographic words on svg page.
Following is an example:
http://www.pinyinology.com/test/characters.svg

Thanks for your expertise.
fulio pen
Sep 12 '08 #1
2 2577
fulio pen wrote:
<svg onload="chinText()" width="100%" height="100%" version="1.1"
xmlns="http://www.w3.org/2000/svg">

<script type='text/ecmascript'>
<![CDATA[
function chinText()
{
document.getElementById("moon").innerHTML ="\u6708"; //javascript
command
Why do you think that inner_HTML_ would work when scripting SVG which is
XML and not HTML?
<text id="moon" x="128" y="150" style="fill:blue; font-family:times;
font-size:150%; font-weight:700; stroke:none;">Character fails to
appear here.</text//svg tags for the character.

<text id="moon" x="128" y="200" style="fill:red; font-family:times;
font-size:150%; font-weight:600; stroke:none;">This character will
appear at 4 locations in this page.</text>
</svg>
And why do you have two elements with the same id attribute value
"moon"? That is not allowed, id values must be unique in the complete
document.

So get rid of the duplicated ids, then make sure you use the W3C DOM
Core methods e.g.
var textNode = document.createTextNode("\u6708");
someElement.appendChild(textNode);
to append that character to an element or if you know an element has as
its first child a text node then you can use
someElement.firstChild.nodeValue = "\u6708";

--

Martin Honnen
http://JavaScript.FAQTs.com/
Sep 12 '08 #2
On Sep 12, 7:23*am, Martin Honnen <mahotr...@yahoo.dewrote:
fulio pen wrote:
<svg *onload="chinText()" width="100%" height="100%" version="1.1"
xmlns="http://www.w3.org/2000/svg">
<script type='text/ecmascript'>
<![CDATA[
function chinText()
{
* document.getElementById("moon").innerHTML ="\u6708"; //javascript
command

Why do you think that inner_HTML_ would work when scripting SVG which is
XML and not HTML?
<text id="moon" x="128" y="150" style="fill:blue; font-family:times;
font-size:150%; font-weight:700; stroke:none;">Character fails to
appear here.</text//svg tags for the character.
<text id="moon" x="128" y="200" style="fill:red; font-family:times;
font-size:150%; font-weight:600; stroke:none;">This character will
appear at 4 locations in this page.</text>
</svg>

And why do you have two elements with the same id attribute value
"moon"? That is not allowed, id values must be unique in the complete
document.

So get rid of the duplicated ids, then make sure you use the W3C DOM
Core methods e.g.
* *var textNode = document.createTextNode("\u6708");
* *someElement.appendChild(textNode);
to append that character to an element or if you know an element has as
its first child a text node then you can use
* *someElement.firstChild.nodeValue = "\u6708";

--

* * * * Martin Honnen
* * * *http://JavaScript.FAQTs.com/
Hi, Martin:

Thanks a lot for your help.

Fulio
Sep 12 '08 #3

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

Similar topics

4
by: Knackeback | last post by:
Hi, I wrote a XML file with GNU emacs 21.2.2 and with chinese character content encoded in UTF-8. I wrote something like: <?xml version="1.0" encoding="UTF-8"?> <test> <chinese>¼»</chinese>...
6
by: Zhang Weiwu | last post by:
Hello. I am working with a php software project, in it (www.egroupware.org) Chinese simplified locate is "zh" while Traditional Chinese "tw". I wish to send correct language attribute in http...
1
by: Marshall | last post by:
Our company is writing a forum software that can handle English and Chinese posts. So that those without Chinese fonts etc can avoid trouble viewing our site, we'd like to on the fly change any...
12
by: Steven Nagy | last post by:
Hi all, I have to do a website in chinese! Basically I just need to know how to output chinese characters. I am assuming its very easy, but have never done it before. I can however do simple...
13
by: monomaniac21 | last post by:
hi i want to be able to trigger a javascript style popup alert in php (i want a message displayed on the actual page) is this possible?
16
by: Tony Girgenti | last post by:
Hello. I just finished reading two articles about javascript here: http://msdn2.microsoft.com/en-us/library/bb332123(VS.80).aspx I tried some javascript testing in VS2005, SP1, VB , .NET 2.0,...
2
by: Clive Green | last post by:
Hello peeps, I am using PHP 5.2.2 together with MP3_Id (a PEAR module for reading and writing MP3 tags). I have been using PHP on the command line (Mac OS X Unix shell, to be precise), and am...
12
by: Steve Howell | last post by:
The never-ending debate about PEP 3131 got me thinking about natural languages with respect to Python, and I have a bunch of mostly simple observations (some factual, some anecdotal). I present...
0
by: manojuniverse | last post by:
Hi I am writing a functionality to export a file as...cs file ---------=- Response.Buffer = true; Response.ContentType = "application/vnd.ms-excel"; Response.ContentEncoding =...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
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.