473,472 Members | 1,882 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

svg in firefox

Hi, I am creating a legend for my webpage.
I am using svg to draw rectangles. But somehow it just draws one
rectangle only.
Here is the code.
var rColor=new Array();
var legendArr=[];
var svgPaint = document.getElementById("inlineMapLegendPopup");

document.getElementById("inlineMapLegendPopup").in nerHTML ="";
rColor = [ 'blue', 'red', '#4CC417' ];
var str = "<font color='Red'><u><b><h4>VML SVG Test</h4></u></font>"
str = str + 'Color 1'
var j=10;
var doc=[];
for(var a=0;a<3;a++)
{
doc[a] = new DOMParser().parseFromString('<svg xmlns="http://
www.w3.org/2000/svg"><rect x="' + j + '" y="'+ j + '" width="30"
height="20" style="fill:'+ rColor[a] + ';stroke-width:1;
stroke:rgb(1,1,0)"/></svg>', 'application/xml');
legendArr[a] =
svgPaint.ownerDocument.importNode(doc[a].documentElement,true);
j=j+10;
svgPaint.appendChild(legendArr[a]);
}

I dont know, why for loop is not working?
It's just drawing one rectangle only, instead of three.
Nov 4 '08 #1
1 2059
On Nov 5, 6:55*am, webmaniac <sunnyluth...@gmail.comwrote:
Hi, I am creating a legend for my webpage.
I am using svg to draw rectangles. But somehow it just draws one
rectangle only.
Here is the code.
Please manually wrap code at about 70 characters for posting so others
can just cut and paste without auto-wrapping introducing errors.
Also, complete code that shows the issue is good, so I've added a bit
of HTML around the code:

<div id="inlineMapLegendPopup"></div>
<script type="text/javascript">

var legendArr = [];
var svgPaint = document.getElementById("inlineMapLegendPopup");
var rColor = [ 'blue', 'red', '#4CC417' ];
var str = "<font color='Red'><u><b><h4>VML SVG Test</h4>" +
"</u></font>Color 1";
var j = 10;
var doc = [];

svgPaint.innerHTML = "";

for (var a=0; a<3; a++) {
doc[a] = new DOMParser().parseFromString(
'<svg xmlns="http://www.w3.org/2000/svg"><rect x="' +
j + '" y="'+ j +
'" width="30" height="20" style="fill:' +
rColor[a] +
';stroke-width:1; stroke:rgb(1,1,0)"/></svg>',
'application/xml');
legendArr[a] = svgPaint.ownerDocument.importNode(
doc[a].documentElement, true);
j = j+10;
svgPaint.appendChild(legendArr[a]);
}
</script>

I dont know, why for loop is not working?
It's just drawing one rectangle only, instead of three.
The above draws 3 rectangles for me in Firefox 3.0.3.
--
Rob
Nov 5 '08 #2

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

Similar topics

3
by: Jeremy Epstein | last post by:
I've got a 4-page form that lets users enter a whole lot of information, which is then submitted and emailed at the end. All the fields are stored as session data. The whole thing works fine: ...
6
by: Geoff | last post by:
When trying to focus a field in Firefox, I get the following error: Error: " nsresult: "0x8057001e (NS_ERROR_XPC_JS_THREW_STRING)" location: "JS frame ::...
87
by: expertware | last post by:
Dear friends, My name is Pamela, I know little about CSS, but I would like to ask a question I have an image on a web page within a css layer: <DIV ID=MyLayer STYLE = "position:...
14
by: expertware | last post by:
Ok! to avoid confusion I will start a new argument. Thanks!! FIREFOX 1.0.7 AND IE6 viewed through DATATIME: a summary REPORT ===============================================================...
5
by: SPE - Stani's Python Editor | last post by:
Hi, During optimizing SPE for Ubuntu, I found something strange. I have Ubuntu 5.10 "The Breezy Badger" and unfortunately this code is not working: >>> import webbrowser >>>...
7
by: Coder | last post by:
Hi I have the following code in java script, it is not giving proper output in FIREFOX but running fine in IE... can anybody help me out to make this run in FIREFOX . <script...
12
by: amit | last post by:
Hello group, I'm kinda skeptical about a code is being used in my js program. All it does is checking what browser is being run and finds out if FLASH is installed or not. This code works...
6
by: scotty | last post by:
I have a script that loops through an existing table list and prepares each href element node to trigger a function when an image is clicked. The function that will be run passes a property value...
7
by: Carlos Mendonça | last post by:
Has anyone managed to get ClickOnce to work with Firefox? It seems to me that it still has the same issues VS 2K5 had. I appreciate any comments or tips.
3
by: SAL | last post by:
Hello, I did google this issue and found some stuff related to BrowserCaps section of either web.config or machine.config but it didn't work. It seems that most pages in my webapp are okay but a...
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...
1
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
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
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,...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

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.