Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.javascript > #28494

Re: short script -- what is wrong?

Newsgroups comp.lang.javascript
Subject Re: short script -- what is wrong?
From "Evertjan." <exxjxw.hannivoort@inter.nl.net>
References <103306d5-085e-41c7-950a-fcf3edfcd430@googlegroups.com>
Date 2015-08-04 11:17 +0200
Message-ID <XnsA4EC72F023021eejj99@194.109.6.166> (permalink)

Show all headers | View raw


Jay Braun <lyngwyst@gmail.com> wrote on 04 Aug 2015 in
comp.lang.javascript: 

> In my application, I will need to create and update several squares and
> other shapes over time.  So I will need a script.  I tried the following
> to try scripting the single red square, but nothing displays.  Note that
> I have added id and onload attributes to the svg element: 
> 
> <?xml version="1.0" standalone="no"?>
> <!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 20010904//EN"
>  "http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd">
> <svg version="1.0" xmlns="http://www.w3.org/2000/svg"
> width="2188.000000pt" height="1312.000000pt" viewBox="0 0 2188.000000
> 1312.000000" preserveAspectRatio="xMidYMid meet" iid="bigbox"

iid= will never do id=

However

> onload="init()" > 

why not do:

onload="init(this)"

[..]

> function init() {
>    var bigbox=document.getElementById("bigbox");

and:

function init(bigbox) {
   //var bigbox=document.getElementById("bigbox");


>    var ns="http://www.w3.org/2000/svg";
> 
[..]
>}
> </script>
> 
> </g>
> </svg>
> 
> I suspect that my error(s) will be obvious to the experts here.  Thanks,
> Jay

Methinks the mixture of ready svg and javascript induced shapes
makes the whole thing error-prone. I for one can't even deduce what you want 
to show.

Look at this nice and less error-prone full-javascript way:

<http://solvedstack.com/questions/javascript-createelement> 

Add just <!DOCTYPE HTML> to the top,
with that and var xmlns = "http://www.w3.org/2000/svg"
you don't seem to need the whole rigmarole.

You can inspect the resulting svg-code in the body
using F12 [in Chrome and other browsers] 

-- 
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)

Back to comp.lang.javascript | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

short script -- what is wrong? Jay Braun <lyngwyst@gmail.com> - 2015-08-03 20:02 -0700
  Re: short script -- what is wrong? "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2015-08-04 11:17 +0200
  Re: short script -- what is wrong? Martin Honnen <mahotrash@yahoo.de> - 2015-08-04 11:19 +0200
  Re: short script -- what is wrong? Jay Braun <lyngwyst@gmail.com> - 2015-08-04 05:35 -0700
  Re: short script -- what is wrong? Jay Braun <lyngwyst@gmail.com> - 2015-08-04 06:00 -0700
    Re: short script -- what is wrong? "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2015-08-04 15:20 +0200
      Re: short script -- what is wrong? Jay Braun <lyngwyst@gmail.com> - 2015-08-04 06:45 -0700
        Re: short script -- what is wrong? "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2015-08-04 15:59 +0200

csiph-web