Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.javascript > #38271 > unrolled thread
| Started by | Jonas Thörnvall <jonas.thornvall@gmail.com> |
|---|---|
| First post | 2020-03-19 22:22 -0700 |
| Last post | 2020-03-31 17:07 +0200 |
| Articles | 18 — 6 participants |
Back to article view | Back to comp.lang.javascript
How can i have semicolon ";" as part of string? Jonas Thörnvall <jonas.thornvall@gmail.com> - 2020-03-19 22:22 -0700
Re: How can i have semicolon ";" as part of string? Jonas Thörnvall <jonas.thornvall@gmail.com> - 2020-03-19 23:54 -0700
Re: How can i have semicolon ";" as part of string? Jonas Thörnvall <jonas.thornvall@gmail.com> - 2020-03-20 00:01 -0700
Re: How can i have semicolon ";" as part of string? Jonas Thörnvall <jonas.thornvall@gmail.com> - 2020-03-20 00:03 -0700
Re: How can i have semicolon ";" as part of string? Jonas Thörnvall <jonas.thornvall@gmail.com> - 2020-03-20 00:14 -0700
Re: How can i have semicolon ";" as part of string? Jonas Thörnvall <jonas.thornvall@gmail.com> - 2020-03-20 00:21 -0700
Re: How can i have semicolon ";" as part of string? Julio Di Egidio <julio@diegidio.name> - 2020-03-20 01:20 -0700
Re: How can i have semicolon ";" as part of string? Jonas Thörnvall <jonas.thornvall@gmail.com> - 2020-03-20 02:45 -0700
Re: How can i have semicolon ";" as part of string? Julio Di Egidio <julio@diegidio.name> - 2020-03-20 10:04 -0700
Re: How can i have semicolon ";" as part of string? Jonas Thörnvall <jonas.thornvall@gmail.com> - 2020-03-20 20:47 -0700
Re: How can i have semicolon ";" as part of string? Julio Di Egidio <julio@diegidio.name> - 2020-03-20 12:07 -0700
Re: How can i have semicolon ";" as part of string? Jonas Thörnvall <jonas.thornvall@gmail.com> - 2020-03-20 02:50 -0700
Re: How can i have semicolon ";" as part of string? JJ <jj4public@vfemail.net> - 2020-03-20 22:08 +0700
Re: How can i have semicolon ";" as part of string? "Michael Haufe (TNO)" <tno@thenewobjective.com> - 2020-03-20 08:53 -0700
Re: How can i have semicolon ";" as part of string? "Michael Haufe (TNO)" <tno@thenewobjective.com> - 2020-03-20 08:50 -0700
Re: How can i have semicolon ";" as part of string? Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2020-03-31 03:16 +0200
Re: How can i have semicolon ";" as part of string? Jon Ribbens <jon+usenet@unequivocal.eu> - 2020-03-31 10:29 +0000
Re: How can i have semicolon ";" as part of string? Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2020-03-31 17:07 +0200
| From | Jonas Thörnvall <jonas.thornvall@gmail.com> |
|---|---|
| Date | 2020-03-19 22:22 -0700 |
| Subject | How can i have semicolon ";" as part of string? |
| Message-ID | <56c23884-8adb-4a05-8646-b70e6649ae12@googlegroups.com> |
This string is correct built
mySliders[mySliders.length]="<div id='sliderContainer"+mySliders.length+"'>\n<input type='range' min='1' max='100' value='10' orient='vertical'></div>";
This one gives error i suspect is the semicolon, how can i have semicolon in string
mySliders[mySliders.length]="<div id='sliderContainer"+mySliders.length+"'>\n<input type='range' min='1' max='100' value='10' orient='vertical'></div> <script> dragElement(document.getElementById('sliderContainer')); </script>";
[toc] | [next] | [standalone]
| From | Jonas Thörnvall <jonas.thornvall@gmail.com> |
|---|---|
| Date | 2020-03-19 23:54 -0700 |
| Message-ID | <fd0fcdad-b1e5-4d61-a281-9485b45c83a5@googlegroups.com> |
| In reply to | #38271 |
Den fredag 20 mars 2020 kl. 06:23:03 UTC+1 skrev Jonas Thörnvall:
> This string is correct built
>
> mySliders[mySliders.length]="<div id='sliderContainer"+mySliders.length+"'>\n<input type='range' min='1' max='100' value='10' orient='vertical'></div>";
>
>
> This one gives error i suspect is the semicolon, how can i have semicolon in string
>
> mySliders[mySliders.length]="<div id='sliderContainer"+mySliders.length+"'>\n<input type='range' min='1' max='100' value='10' orient='vertical'></div> <script> dragElement(document.getElementById('sliderContainer')); </script>";
I no longer think it is the semicolon and i do not think it is the brackets. rather i have no idea what it is. So could someone tell me the 3 sek answer to this question, so i can go on building my code generator. "OK, pretty please"
test="<script> dragElement(document.getElementById('sliderContainer')); </script>";
WTF is wrong with the string.
[toc] | [prev] | [next] | [standalone]
| From | Jonas Thörnvall <jonas.thornvall@gmail.com> |
|---|---|
| Date | 2020-03-20 00:01 -0700 |
| Message-ID | <0dc69257-0ac7-47b2-ab50-d739fd347892@googlegroups.com> |
| In reply to | #38273 |
Den fredag 20 mars 2020 kl. 07:54:08 UTC+1 skrev Jonas Thörnvall:
> Den fredag 20 mars 2020 kl. 06:23:03 UTC+1 skrev Jonas Thörnvall:
> > This string is correct built
> >
> > mySliders[mySliders.length]="<div id='sliderContainer"+mySliders.length+"'>\n<input type='range' min='1' max='100' value='10' orient='vertical'></div>";
> >
> >
> > This one gives error i suspect is the semicolon, how can i have semicolon in string
> >
> > mySliders[mySliders.length]="<div id='sliderContainer"+mySliders.length+"'>\n<input type='range' min='1' max='100' value='10' orient='vertical'></div> <script> dragElement(document.getElementById('sliderContainer')); </script>";
>
> I no longer think it is the semicolon and i do not think it is the brackets. rather i have no idea what it is. So could someone tell me the 3 sek answer to this question, so i can go on building my code generator. "OK, pretty please"
>
> test="<script> dragElement(document.getElementById('sliderContainer')); </script>";
>
> WTF is wrong with the string.
Well certainly something is wrong.
<!DOCTYPE html>
<html>
<body>
<h2>JavaScript Strings</h2>
<p id="demo"></p>
<script>
var x = ="<script> dragElement(document.getElementById('sliderContainer')); </script>";
document.getElementById("demo").innerHTML = x;
</script>
</body>
</html>
Have i found a bug in Javascript?
[toc] | [prev] | [next] | [standalone]
| From | Jonas Thörnvall <jonas.thornvall@gmail.com> |
|---|---|
| Date | 2020-03-20 00:03 -0700 |
| Message-ID | <2ffdd28e-ff7f-4ead-8fc8-11b225e2e35e@googlegroups.com> |
| In reply to | #38274 |
Den fredag 20 mars 2020 kl. 08:01:49 UTC+1 skrev Jonas Thörnvall:
> Den fredag 20 mars 2020 kl. 07:54:08 UTC+1 skrev Jonas Thörnvall:
> > Den fredag 20 mars 2020 kl. 06:23:03 UTC+1 skrev Jonas Thörnvall:
> > > This string is correct built
> > >
> > > mySliders[mySliders.length]="<div id='sliderContainer"+mySliders.length+"'>\n<input type='range' min='1' max='100' value='10' orient='vertical'></div>";
> > >
> > >
> > > This one gives error i suspect is the semicolon, how can i have semicolon in string
> > >
> > > mySliders[mySliders.length]="<div id='sliderContainer"+mySliders.length+"'>\n<input type='range' min='1' max='100' value='10' orient='vertical'></div> <script> dragElement(document.getElementById('sliderContainer')); </script>";
> >
> > I no longer think it is the semicolon and i do not think it is the brackets. rather i have no idea what it is. So could someone tell me the 3 sek answer to this question, so i can go on building my code generator. "OK, pretty please"
> >
> > test="<script> dragElement(document.getElementById('sliderContainer')); </script>";
> >
> > WTF is wrong with the string.
>
> Well certainly something is wrong.
>
> <!DOCTYPE html>
> <html>
> <body>
>
> <h2>JavaScript Strings</h2>
>
> <p id="demo"></p>
>
> <script>
> var x = ="<script> dragElement(document.getElementById('sliderContainer')); </script>";
> document.getElementById("demo").innerHTML = x;
> </script>
>
> </body>
> </html>
>
> Have i found a bug in Javascript?
Run here
https://www.w3schools.com/js/tryit.asp?filename=tryjs_string
[toc] | [prev] | [next] | [standalone]
| From | Jonas Thörnvall <jonas.thornvall@gmail.com> |
|---|---|
| Date | 2020-03-20 00:14 -0700 |
| Message-ID | <6c0b3f05-82ed-4081-8701-38179927c390@googlegroups.com> |
| In reply to | #38275 |
Den fredag 20 mars 2020 kl. 08:03:16 UTC+1 skrev Jonas Thörnvall:
> Den fredag 20 mars 2020 kl. 08:01:49 UTC+1 skrev Jonas Thörnvall:
> > Den fredag 20 mars 2020 kl. 07:54:08 UTC+1 skrev Jonas Thörnvall:
> > > Den fredag 20 mars 2020 kl. 06:23:03 UTC+1 skrev Jonas Thörnvall:
> > > > This string is correct built
> > > >
> > > > mySliders[mySliders.length]="<div id='sliderContainer"+mySliders.length+"'>\n<input type='range' min='1' max='100' value='10' orient='vertical'></div>";
> > > >
> > > >
> > > > This one gives error i suspect is the semicolon, how can i have semicolon in string
> > > >
> > > > mySliders[mySliders.length]="<div id='sliderContainer"+mySliders.length+"'>\n<input type='range' min='1' max='100' value='10' orient='vertical'></div> <script> dragElement(document.getElementById('sliderContainer')); </script>";
> > >
> > > I no longer think it is the semicolon and i do not think it is the brackets. rather i have no idea what it is. So could someone tell me the 3 sek answer to this question, so i can go on building my code generator. "OK, pretty please"
> > >
> > > test="<script> dragElement(document.getElementById('sliderContainer')); </script>";
> > >
> > > WTF is wrong with the string.
> >
> > Well certainly something is wrong.
> >
> > <!DOCTYPE html>
> > <html>
> > <body>
> >
> > <h2>JavaScript Strings</h2>
> >
> > <p id="demo"></p>
> >
> > <script>
> > var x = ="<script> dragElement(document.getElementById('sliderContainer')); </script>";
> > document.getElementById("demo").innerHTML = x;
> > </script>
> >
> > </body>
> > </html>
> >
> > Have i found a bug in Javascript?
>
> Run here
> https://www.w3schools.com/js/tryit.asp?filename=tryjs_string
No its ain't the double equal sign that somehow cloned out of nothing.
[toc] | [prev] | [next] | [standalone]
| From | Jonas Thörnvall <jonas.thornvall@gmail.com> |
|---|---|
| Date | 2020-03-20 00:21 -0700 |
| Message-ID | <7166df5d-36f6-4625-b30a-65d9297bb56f@googlegroups.com> |
| In reply to | #38276 |
Den fredag 20 mars 2020 kl. 08:14:40 UTC+1 skrev Jonas Thörnvall:
> Den fredag 20 mars 2020 kl. 08:03:16 UTC+1 skrev Jonas Thörnvall:
> > Den fredag 20 mars 2020 kl. 08:01:49 UTC+1 skrev Jonas Thörnvall:
> > > Den fredag 20 mars 2020 kl. 07:54:08 UTC+1 skrev Jonas Thörnvall:
> > > > Den fredag 20 mars 2020 kl. 06:23:03 UTC+1 skrev Jonas Thörnvall:
> > > > > This string is correct built
> > > > >
> > > > > mySliders[mySliders.length]="<div id='sliderContainer"+mySliders.length+"'>\n<input type='range' min='1' max='100' value='10' orient='vertical'></div>";
> > > > >
> > > > >
> > > > > This one gives error i suspect is the semicolon, how can i have semicolon in string
> > > > >
> > > > > mySliders[mySliders.length]="<div id='sliderContainer"+mySliders.length+"'>\n<input type='range' min='1' max='100' value='10' orient='vertical'></div> <script> dragElement(document.getElementById('sliderContainer')); </script>";
> > > >
> > > > I no longer think it is the semicolon and i do not think it is the brackets. rather i have no idea what it is. So could someone tell me the 3 sek answer to this question, so i can go on building my code generator. "OK, pretty please"
> > > >
> > > > test="<script> dragElement(document.getElementById('sliderContainer')); </script>";
> > > >
> > > > WTF is wrong with the string.
> > >
> > > Well certainly something is wrong.
> > >
> > > <!DOCTYPE html>
> > > <html>
> > > <body>
> > >
> > > <h2>JavaScript Strings</h2>
> > >
> > > <p id="demo"></p>
> > >
> > > <script>
> > > var x = ="<script> dragElement(document.getElementById('sliderContainer')); </script>";
> > > document.getElementById("demo").innerHTML = x;
> > > </script>
> > >
> > > </body>
> > > </html>
> > >
> > > Have i found a bug in Javascript?
> >
> > Run here
> > https://www.w3schools.com/js/tryit.asp?filename=tryjs_string
>
> No its ain't the double equal sign that somehow cloned out of nothing.
Anyone i can't sit and look at this shit, and i can't circumvent it, what is wrong?
[toc] | [prev] | [next] | [standalone]
| From | Julio Di Egidio <julio@diegidio.name> |
|---|---|
| Date | 2020-03-20 01:20 -0700 |
| Message-ID | <73f29960-2358-483f-9a22-967b54eb13fe@googlegroups.com> |
| In reply to | #38274 |
On Friday, 20 March 2020 08:01:49 UTC+1, Jonas Thörnvall wrote:
>
> Well certainly something is wrong.
>
> <!DOCTYPE html>
> <html>
> <body>
>
> <h2>JavaScript Strings</h2>
>
> <p id="demo"></p>
>
> <script>
> var x = "<script> dragElement(document.getElementById('sliderContainer')); </script>";
> document.getElementById("demo").innerHTML = x;
> </script>
>
> </body>
> </html>
>
> Have i found a bug in Javascript?
You are so funny...
First of all, the "</script>" part of the string closes the script tag for the
browser, which you should have seen by just running that (the browser does not
care of quotes in the text), so you'd have to rather write "...</" + "script>";
which happens to be a well known work-around.
Secondly, that still cannot work, you cannot add a script to the page that way:
the *code* string is the innerHTML of a *script* tag eventually, so either you
have that in the page already and just set its innerHTML (as in the example
below), or create a new script element with document.createElement, set its
innerHTML, add the script element to the DOM, usually append to the document
body, and the script will run.
There are subtleties I won't get into, it's pointless as your requirements
overall are as clear as mud, but it smells like, whatever that is, you are
approaching it ass-backwards: not per chance, as you can also see from my
example below, the same can be done with a plain eval...
------------------------
<!DOCTYPE html>
<html>
<body>
<h2>JavaScript Strings</h2>
<script id="script"></script>
<script>
var code = "alert(1);";
document.getElementById("script").innerHTML = code;
</script>
<script>
var code = "alert(2);";
eval(code);
</script>
</body>
</html>
------------------------
You owe me a coffee.
Julio
[toc] | [prev] | [next] | [standalone]
| From | Jonas Thörnvall <jonas.thornvall@gmail.com> |
|---|---|
| Date | 2020-03-20 02:45 -0700 |
| Message-ID | <3eb7f3ea-220d-4878-bc04-b6f7de30b09d@googlegroups.com> |
| In reply to | #38278 |
Den fredag 20 mars 2020 kl. 09:20:07 UTC+1 skrev Julio Di Egidio:
> On Friday, 20 March 2020 08:01:49 UTC+1, Jonas Thörnvall wrote:
> >
> > Well certainly something is wrong.
> >
> > <!DOCTYPE html>
> > <html>
> > <body>
> >
> > <h2>JavaScript Strings</h2>
> >
> > <p id="demo"></p>
> >
> > <script>
> > var x = "<script> dragElement(document.getElementById('sliderContainer')); </script>";
> > document.getElementById("demo").innerHTML = x;
> > </script>
> >
> > </body>
> > </html>
> >
> > Have i found a bug in Javascript?
>
> You are so funny...
>
> First of all, the "</script>" part of the string closes the script tag for the
> browser, which you should have seen by just running that (the browser does not
> care of quotes in the text), so you'd have to rather write "...</" + "script>";
You say the script part of the string, indeed this is muddy are you claiming Javascript can't treat string="</script>"; as a string why it sounds absurd????????? I do understand it is end of script in middle of script, but it is fucking between brackets?????? Doesn't javascrpt notice, can't it distinguish between odd and even number of brackets, is it what you are telling me?
> which happens to be a well known work-around.
>
> Secondly, that still cannot work, you cannot add a script to the page that way:
> the *code* string is the innerHTML of a *script* tag eventually, so either you
> have that in the page already and just set its innerHTML (as in the example
> below), or create a new script element with document.createElement, set its
> innerHTML, add the script element to the DOM, usually append to the document
> body, and the script will run.
>
> There are subtleties I won't get into, it's pointless as your requirements
> overall are as clear as mud, but it smells like, whatever that is, you are
> approaching it ass-backwards: not per chance, as you can also see from my
> example below, the same can be done with a plain eval...
Well basicly what i do is building a HTML,CSS,JAVASCRIPT page in a textarea creating objects out of form. But these objects will be dynamic "floating" with dropdown for their properties. You know like Xerox Smalltalk way, you can change the properties at the object itself. Of course when page saved this meta information will not be there. I do not think eval apply to building dynamic pages with floating objects with dropdowns.
Here is the workflow, using DIVS
<DIV>Object forms holding attributes/properties</DIV>
Built "meta" objects/elements mirrored to
<DIV><TEXTAREA></DIV>
The "thingy" built within text area is then dumped into an inner HTML that i think you suggest i should replace with an eval?
No it is not anything like a general codegenerator, it is just for midi messaging to midi devices so midi message is a property of the objects.
There probably only will be some 10 of objects that is dynamically created and dumped to the inner HTML page, but the MIDI CTRLR page can then be saved without the meta objects.
Basicly it is an adjustable WYSIWYG holding object with their properties in floatable dropdowns. Drag and drop.
> ------------------------
> <!DOCTYPE html>
> <html>
> <body>
>
> <h2>JavaScript Strings</h2>
>
> <script id="script"></script>
>
> <script>
> var code = "alert(1);";
>
> document.getElementById("script").innerHTML = code;
> </script>
>
> <script>
> var code = "alert(2);";
>
> eval(code);
> </script>
>
> </body>
> </html>
> ------------------------
>
> You owe me a coffee.
>
> Julio
[toc] | [prev] | [next] | [standalone]
| From | Julio Di Egidio <julio@diegidio.name> |
|---|---|
| Date | 2020-03-20 10:04 -0700 |
| Message-ID | <f9bbe28b-1390-4aba-9258-217b2c5a49e8@googlegroups.com> |
| In reply to | #38281 |
On Friday, 20 March 2020 10:45:47 UTC+1, Jonas Thörnvall wrote: > No it is not anything like a general codegenerator, it is just for midi > messaging to midi devices so midi message is a property of the objects. > > There probably only will be some 10 of objects that is dynamically created > and dumped to the inner HTML page You don't dump or generate anything, you just need to show in the page a bunch of values that happen to be properties of some object(s), which is perfectly ordinary business, you are just tripping on nomenclature. Learn Knockout.js... Julio
[toc] | [prev] | [next] | [standalone]
| From | Jonas Thörnvall <jonas.thornvall@gmail.com> |
|---|---|
| Date | 2020-03-20 20:47 -0700 |
| Message-ID | <42b114fa-deaf-49e9-86ca-63446563be0a@googlegroups.com> |
| In reply to | #38288 |
Den fredag 20 mars 2020 kl. 18:04:46 UTC+1 skrev Julio Di Egidio: > On Friday, 20 March 2020 10:45:47 UTC+1, Jonas Thörnvall wrote: > > > No it is not anything like a general codegenerator, it is just for midi > > messaging to midi devices so midi message is a property of the objects. > > > > There probably only will be some 10 of objects that is dynamically created > > and dumped to the inner HTML page > > You don't dump or generate anything, you just need to show in the page a bunch > of values that happen to be properties of some object(s), which is perfectly > ordinary business, you are just tripping on nomenclature. > > Learn Knockout.js... > > Julio Ok so you say i should create objects but how are they binded to the inputs fields and updated from form changes? What is the advantage? I think the interface ends up just like when building/generating the code with form values attached to strings. I mean the syntax part of "html,js,css" will be strings in an array anyway. So what you gain by putting the values in objects, you must anyway adress each attribute/property i can as well have an array for each property building the object, as an array for full object. What would the advantage be, i can as well build my "strings" and "page" from indexed properties in arrays, yeah a little messier when dropping element or updating. But it probably evens out because complexity doing with objects harder. ***Only alot harder to implement***
[toc] | [prev] | [next] | [standalone]
| From | Julio Di Egidio <julio@diegidio.name> |
|---|---|
| Date | 2020-03-20 12:07 -0700 |
| Message-ID | <1c04abf2-60ca-4401-9f05-efc6160641ae@googlegroups.com> |
| In reply to | #38281 |
On Friday, 20 March 2020 10:45:47 UTC+1, Jonas Thörnvall wrote: > Den fredag 20 mars 2020 kl. 09:20:07 UTC+1 skrev Julio Di Egidio: > > First of all, the "</script>" part of the string closes the script tag for the > > browser, which you should have seen by just running that (the browser does not > > care of quotes in the text), so you'd have to rather write "...</" + "script>"; > > You say the script part of the string, indeed this is muddy are you claiming > Javascript can't treat string="</script>"; as a string I said *for the browser*. Of course it is a perfectly valid JS string, the problem is if you put that verbatim into the HTML, you are messing up *the HTML*! Julio
[toc] | [prev] | [next] | [standalone]
| From | Jonas Thörnvall <jonas.thornvall@gmail.com> |
|---|---|
| Date | 2020-03-20 02:50 -0700 |
| Message-ID | <737323d5-5f1c-42a8-bd95-0da70fedbad9@googlegroups.com> |
| In reply to | #38278 |
Den fredag 20 mars 2020 kl. 09:20:07 UTC+1 skrev Julio Di Egidio:
> On Friday, 20 March 2020 08:01:49 UTC+1, Jonas Thörnvall wrote:
> >
> > Well certainly something is wrong.
> >
> > <!DOCTYPE html>
> > <html>
> > <body>
> >
> > <h2>JavaScript Strings</h2>
> >
> > <p id="demo"></p>
> >
> > <script>
> > var x = "<script> dragElement(document.getElementById('sliderContainer')); </script>";
> > document.getElementById("demo").innerHTML = x;
> > </script>
> >
> > </body>
> > </html>
> >
> > Have i found a bug in Javascript?
>
> You are so funny...
>
> First of all, the "</script>" part of the string closes the script tag for the
> browser, which you should have seen by just running that (the browser does not
> care of quotes in the text), so you'd have to rather write "...</" + "script>";
> which happens to be a well known work-around.
>
> Secondly, that still cannot work, you cannot add a script to the page that way:
> the *code* string is the innerHTML of a *script* tag eventually, so either you
> have that in the page already and just set its innerHTML (as in the example
> below), or create a new script element with document.createElement, set its
> innerHTML, add the script element to the DOM, usually append to the document
> body, and the script will run.
>
> There are subtleties I won't get into, it's pointless as your requirements
> overall are as clear as mud, but it smells like, whatever that is, you are
> approaching it ass-backwards: not per chance, as you can also see from my
> example below, the same can be done with a plain eval...
>
> ------------------------
> <!DOCTYPE html>
> <html>
> <body>
>
> <h2>JavaScript Strings</h2>
>
> <script id="script"></script>
>
> <script>
> var code = "alert(1);";
>
> document.getElementById("script").innerHTML = code;
> </script>
>
> <script>
> var code = "alert(2);";
>
> eval(code);
> </script>
>
> </body>
> </html>
> ------------------------
>
> You owe me a coffee.
>
> Julio
Oh thanks Julio!
[toc] | [prev] | [next] | [standalone]
| From | JJ <jj4public@vfemail.net> |
|---|---|
| Date | 2020-03-20 22:08 +0700 |
| Message-ID | <1gtin5hdxvwrl$.liz0jo21qyfk.dlg@40tude.net> |
| In reply to | #38278 |
On Fri, 20 Mar 2020 01:20:01 -0700 (PDT), Julio Di Egidio wrote:
>
> <script id="script"></script>
>
> <script>
> var code = "alert(1);";
>
> document.getElementById("script").innerHTML = code;
> </script>
It should also be mentioned that once a SCRIPT element has executed its
code, any changes to it won't make it execute any other code. i.e. it's only
effective for one time only. e.g.
<script id="script1"></script>
<script>
var value = 123;
document.getElementById("script1").innerHTML = "value=456";
console.log(value); //456
document.getElementById("script1").innerHTML = "value=789";
console.log(value); //456
</script>
<script id="script2"> </script>
<script>
var value2 = 111;
document.getElementById("script2").innerHTML = "value2=222";
console.log(value2); //111
</script>
<script id="script3" src="data:,value3=333"></script>
<script>
console.log(value3); //333
document.getElementById("script3").src = "data:,value=444";
console.log(value3); //333
</script>
[toc] | [prev] | [next] | [standalone]
| From | "Michael Haufe (TNO)" <tno@thenewobjective.com> |
|---|---|
| Date | 2020-03-20 08:53 -0700 |
| Message-ID | <41d89dab-4413-4276-a47a-a3abf26cc205@googlegroups.com> |
| In reply to | #38274 |
On Friday, March 20, 2020 at 2:01:49 AM UTC-5, Jonas Thörnvall wrote:
> Well certainly something is wrong.
>
> <!DOCTYPE html>
> <html>
> <body>
>
> <h2>JavaScript Strings</h2>
>
> <p id="demo"></p>
>
> <script>
> var x = ="<script> dragElement(document.getElementById('sliderContainer')); </script>";
> document.getElementById("demo").innerHTML = x;
> </script>
>
> </body>
> </html>
>
> Have i found a bug in Javascript?
No, you found a security feature:
<https://www.w3.org/TR/2008/WD-html5-20080610/dom.html#innerhtml0>
quote:
"script elements inserted using innerHTML do not execute when they are inserted."
So stop doing that.
[toc] | [prev] | [next] | [standalone]
| From | "Michael Haufe (TNO)" <tno@thenewobjective.com> |
|---|---|
| Date | 2020-03-20 08:50 -0700 |
| Message-ID | <4f558e8d-6b96-4a6d-a4f0-73187351b2aa@googlegroups.com> |
| In reply to | #38271 |
On Friday, March 20, 2020 at 12:23:03 AM UTC-5, Jonas Thörnvall wrote:
> This string is correct built
>
> mySliders[mySliders.length]="<div id='sliderContainer"+mySliders.length+"'>\n<input type='range' min='1' max='100' value='10' orient='vertical'></div>";
>
>
> This one gives error i suspect is the semicolon, how can i have semicolon in string
>
> mySliders[mySliders.length]="<div id='sliderContainer"+mySliders.length+"'>\n<input type='range' min='1' max='100' value='10' orient='vertical'></div> <script> dragElement(document.getElementById('sliderContainer')); </script>";
Just use the DOM api and stop building a string:
```
let div = document.createElement('div')
div.id = `sliderContainer${mySliders.length}`
let input = document.createElement('input')
Object.assign(input, {
type: 'range',
min: 1,
max: 100,
value: 10
})
// don't make a custom attribute. use data-orient or use a css class
input.dataset.orient = 'vertical'
div.appendChild(input)
mySliders.push(div)
```
Regarding dragElement, I'm not sure what you're trying to accomplish there.
You should probably add a class declaration to your div and attach what I believe to be your event listener after the list is made.
Also, this is probably already provided for you out of the box:
https://developer.mozilla.org/en-US/docs/Web/API/HTML_Drag_and_Drop_API/Drag_operations
[toc] | [prev] | [next] | [standalone]
| From | Thomas 'PointedEars' Lahn <PointedEars@web.de> |
|---|---|
| Date | 2020-03-31 03:16 +0200 |
| Message-ID | <5343239.DvuYhMxLoT@PointedEars.de> |
| In reply to | #38285 |
Michael Haufe (TNO) wrote: > // don't make a custom attribute. use data-orient or use a css class > input.dataset.orient = 'vertical' Thanks for pointing out the “dataset” property. There goes another unnecessary call of setAttribute(), although perhaps by wrapper for some time (IE/MSHTML < 11 does not support it.) <https://developer.mozilla.org/en-US/docs/Learn/HTML/Howto/Use_data_attributes> I notice, with a frown, that <https://www.w3.org/TR/2014/REC-html5-20141028/> now says that it is outdated and recommends to go to <http://www.w3.org/TR/html5/> which redirects to <https://html.spec.whatwg.org/multipage/> The same is true for <https://www.w3.org/TR/html/> as referred by <https://www.w3.org/TR/2017/REC-html52-20171214/> The latest W3C HTML Working Draft is from 2018: <https://www.w3.org/TR/html53/> The URI of the Editor’s Draft referred there, <https://w3c.github.io/html/> redirects to <https://html.spec.whatwg.org/>, too. So apparently W3C HTML is officially dead now :-( -- PointedEars FAQ: <http://PointedEars.de/faq> | <http://PointedEars.de/es-matrix> <https://github.com/PointedEars> | <http://PointedEars.de/wsvn/> Twitter: @PointedEars2 | Please do not cc me./Bitte keine Kopien per E-Mail.
[toc] | [prev] | [next] | [standalone]
| From | Jon Ribbens <jon+usenet@unequivocal.eu> |
|---|---|
| Date | 2020-03-31 10:29 +0000 |
| Message-ID | <slrnr866sd.4v4.jon+usenet@sable.unequivocal.eu> |
| In reply to | #38346 |
On 2020-03-31, Thomas 'PointedEars' Lahn <PointedEars@web.de> wrote: > I notice, with a frown, that > > <https://www.w3.org/TR/2014/REC-html5-20141028/> > > now says that it is outdated and recommends to go to > > <http://www.w3.org/TR/html5/> > > which redirects to > > <https://html.spec.whatwg.org/multipage/> > > The same is true for > > <https://www.w3.org/TR/html/> > > as referred by > > <https://www.w3.org/TR/2017/REC-html52-20171214/> > > The latest W3C HTML Working Draft is from 2018: > > <https://www.w3.org/TR/html53/> > > The URI of the Editor’s Draft referred there, > > <https://w3c.github.io/html/> > > redirects to > > <https://html.spec.whatwg.org/>, > > too. > > So apparently W3C HTML is officially dead now :-( Yes, they announced this without much fanfare last May: https://www.w3.org/blog/2019/05/w3c-and-whatwg-to-work-together-to-advance-the-open-web-platform/ So apparently the "living standard" aka "there is no standard as it can and will frequently change without notice" is the new normal. The announcement claims the W3C will snapshot the document every now and again to produce a Recommendation but they don't seem to have done this at any point in the last year. The W3C updated the links on their site after I pointed out to them that they had contradictory information in different places (and, e.g. the W3C validator was generating errors that contradicted the specification it pointed you to to explain them).
[toc] | [prev] | [next] | [standalone]
| From | Thomas 'PointedEars' Lahn <PointedEars@web.de> |
|---|---|
| Date | 2020-03-31 17:07 +0200 |
| Message-ID | <4221662.LvFx2qVVIh@PointedEars.de> |
| In reply to | #38347 |
Jon Ribbens wrote: > On 2020-03-31, Thomas 'PointedEars' Lahn <PointedEars@web.de> wrote: >> The URI of the Editor’s Draft referred >> [at <https://www.w3.org/TR/html53/>], >> >> <https://w3c.github.io/html/> >> >> redirects to >> >> <https://html.spec.whatwg.org/>, >> >> too. >> >> So apparently W3C HTML is officially dead now :-( > > Yes, they announced this without much fanfare last May: > > https://www.w3.org/blog/2019/05/w3c-and-whatwg-to-work-together-to-advance-the-open-web-platform/ > > So apparently the "living standard" aka "there is no standard as it > can and will frequently change without notice" is the new normal. :-( > The announcement claims the W3C will snapshot the document every now > and again to produce a Recommendation but they don't seem to have > done this at any point in the last year. > > The W3C updated the links on their site after I pointed out to them > that they had contradictory information in different places (and, > e.g. the W3C validator was generating errors that contradicted the > specification it pointed you to to explain them). Thank you for the information and your efforts regarding clarification. -- PointedEars FAQ: <http://PointedEars.de/faq> | <http://PointedEars.de/es-matrix> <https://github.com/PointedEars> | <http://PointedEars.de/wsvn/> Twitter: @PointedEars2 | Please do not cc me./Bitte keine Kopien per E-Mail.
[toc] | [prev] | [standalone]
Back to top | Article view | comp.lang.javascript
csiph-web