• Browser-dependent JavaScript problem

    From John Stockton@21:1/5 to Thomas 'PointedEars' Lahn on Fri May 28 15:36:46 2021
    On Monday, 24 May 2021 at 01:24:26 UTC+1, Thomas 'PointedEars' Lahn wrote
    (***) too much writing, with not enough thinking.

    Andrew Poulos wrote:

    On 24/05/2021 1:58 am, John Stockton wrote:
    I have not been able to access this newsgroup for a while.
    It shows :-D
    The following code was written in Firefox, and works there; it is called >> in a script element which immediately follows <BODY>. it puts something >> like
    × FREDERIC.HTM - saved @ LCT 2021-05-22 Sat ×
    in the bottom right-hand corner of the window.

    But it does not work in Chrome, Vivaldi, Opera, AVG Secure Browser, or
    Edge.
    Of those, Chrome, Opera, _Avast_ Secure Browser, and Edge are now Chromium- based, i.e. use Blink as layout engine. Vivaldi is an attempt to preserve the original Opera’s Presto layout engine.
    In IE11, the style setting has no effect, and the unadorned string
    appears top right. OS is Windows 10.
    IE 11’s layout engine is still MSHTML.

    Note:

    “Internet Explorer 11 follows the OS component lifecycle,[7] which means it
    remains supported with technical and security fixes while operating systems including it as a component are shipped. This means that there is no date for end of support for Internet Explorer 11.[8] On August 17, 2020, Microsoft published a timeline indicating that the Microsoft Teams product would stop supporting Internet Explorer 11 on November 30, 2020, and Microsoft 365 products will end Internet Explorer 11 support on August 17, 2021.[9]”

    <https://en.wikipedia.org/wiki/Internet_Explorer_11>



    (***) I have seen, somewhere, a recent authoritative statement which indicates much the same dates but about a year later.



    […]
    function Show_Age() { // Needs INC-DATE.JS or do not use YMDDstr
    var ND = new Date(), LM = new Date(document.lastModified)
    if ((ND-LM) > 1500 && +LM > 1e12) {
    var El = document.createElement("div")
    El.style = "bottom: 0px; right: 0px; position: fixed; background:
    silver; width: auto; text-align: center; border-radius: 1ex;
    padding: 0.3ex 1.2ex; font-family: sans-serif;"
    El.className = "NPR" // assumes styles-a.css
    El.appendChild(document.createTextNode("\xD7 " +
    location.pathname.replace(/.*\//, "").toUpperCase() +
    " - saved @ LCT " + LM.YMDDstr() + " \xD7"))
    El.onclick = function() { this.style.display = "none" }
    }
    document.body.appendChild(El) }
    True programmers can write Pascal code in any programming language :-D

    Compare: <https://github.com/airbnb/javascript>
    Any suggestions?

    I don't think you can set an element's style the way you are doing it.
    That is correct. “style” is historically a *read-only* *object* property[1], and has been FOR 20 YEARS NOW [2].

    Only as per the WHATWG DOM one may assign a string value to it, as a shorthand.[3]

    A backwards-compatible possibility would be to set the “style” attribute to
    that primitive string value. But it is better to append a stylesheet, and then format based on CSS class names.

    That had no effect - neither better nor worse.

    [1] <https://developer.mozilla.org/en-US/docs/Web/API/ElementCSSInlineStyle/style>

    [2] <https://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-html.html>
    <http://www.w3.org/TR/2000/CR-DOM-Level-2-20000510/html.html#ID-58190037> <http://www.w3.org/TR/2000/CR-DOM-Level-2-20000510/css.html#CSS-htmlelementcss>

    [3] <https://html.spec.whatwg.org/multipage/dom.html#the-style-attribute>
    Maybe try this

    function Show_Age() { // Needs INC-DATE.JS or do not use YMDDstr
    var ND = new Date(),
    LM = new Date(document.lastModified);
    if ((ND-LM) > 1500 && +LM > 1e12) {
    var El = document.createElement("div");
    El.style.bottom = "0px";
    El.style.right = "0px";
    El.style.position = "fixed";
    El.style.background = "silver";
    El.style.textAlign = "center";
    El.style.borderRadius = "1ex";
    El.style.padding = "0.3ex 1.2ex";
    El.style.fontFamily = "sans-serif";
    El.className = "NPR"; // assumes styles-a.css El.appendChild(document.createTextNode("\xD7 " + location.pathname.replace(/.*\//, "").toUpperCase() +
    " - saved @ LCT " + LM.YMDDstr() + " \xD7"));
    El.onclick = function() { this.style.display = "none" }; document.body.appendChild(El);
    El = null;
    This line is pointless, unless *perhaps* you want to support IE < 7.

    }
    }

    The above can be greatly simplified:

    function show_age()
    {
    var
    now = new Date(),
    last_mod = new Date(document.lastModified);

    if (!((now - last_mod) > 1500 && +last_mod > 1e12)) return;

    var el = document.createElement("div");
    Object.assign(el.style, {
    bottom: "0px",
    right: "0px",
    position: "fixed",
    background: "silver",
    textAlign: "center",
    borderRadius: "1ex",
    padding: "0.3ex 1.2ex",
    fontFamily: "sans-serif",
    });

    el.className = "NPR";

    el.appendChild(
    document.createTextNode("\xD7 "
    + window.location.pathname.replace(/.*\//, "").toUpperCase()
    + " - saved @ LCT " + LM.YMDDstr() + " \xD7"));
    el.onclick = function() { this.style.display = "none" }; document.body.appendChild(el);
    }

    But, AISB, for a consistent layout it is better to append a stylesheet (if that is supported in the target environments):

    let style_source = `.npr2 {
    bottom: 0px;
    right: 0px;
    position: fixed;
    background: silver;
    width: auto;
    text-align: center;
    border-radius: 1ex;
    padding: 0.3ex 1.2ex;
    font-family: sans-serif;
    }`;

    let style = document.createElement('style');
    style.type = 'text/css'; style.appendChild(document.createTextNode(style_source)); document.head.appendChild(style);

    el.className = "NPR npr2";

    In case it cannot be assumed that template strings are supported, Array.prototype.join() may be used instead to avoid spaghetti code.


    ---- EOF -----

    (*** ...)

    "Rem acu non tetigisti" - as PGW might have written, but apparently did not (though a very few others did).


    With the original code, most browsers tried would say something like
    // Uncaught TypeError: Failed to execute 'appendChild' on
    // 'Node': parameter 1 is not of type 'Node'.
    // at Show_Age (inc-cmmn.js:60)
    // at fred-set.htm:17

    from which I subsequently deduced that when createTextNode is fed with a non-string argument it (maybe an undefined one) returns a non-Node of disgust which fatally upsets appendChild. And from that, I thought that the LM of LM.YMDDstr() must actually
    be a Date Object in Firefox but not in Chrome, etc. Pragmatically, I tried making LM a Global Variable, and the resulting code worked both in Firefox and in Opera. To avoid an unnecessary Global, I now use new Date(document.lastModified).YMDDstr()
    instead, which works in all browsers that I tried except for the Internet Explorer in my Windows 10.

    Unfortunately, I want that operation to occur for my current "client", who resides about three metres below me with his Windows 7 PC and is about to receive a Windows 10 PC donated to us yesterday, and who should be given code for the above operation in
    his pseudo-home-page, and who is an MS IE fan. However, if it fails harmlessly he'll never know.

    I cannot recall why, ages ago, I included the conditionals - so I've commented them out.

    Progress has been made.

    --
    (c) John Stockton, near London, UK. Using Google Groups. |
    Mail: J.R.""""""""@physics.org - or as Reply-To, if any. |

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From John Stockton@21:1/5 to John Stockton on Sat May 29 13:24:54 2021
    On Friday, 28 May 2021 at 23:36:51 UTC+1, John Stockton wrote:
    On Monday, 24 May 2021 at 01:24:26 UTC+1, Thomas 'PointedEars' Lahn wrote

    Note:

    “Internet Explorer 11 follows the OS component lifecycle,[7] which means it
    remains supported with technical and security fixes while operating systems
    including it as a component are shipped. This means that there is no date for end of support for Internet Explorer 11.[8] On August 17, 2020, Microsoft published a timeline indicating that the Microsoft Teams product would stop supporting Internet Explorer 11 on November 30, 2020, and Microsoft 365 products will end Internet Explorer 11 support on August 17, 2021.[9]”

    <https://en.wikipedia.org/wiki/Internet_Explorer_11>

    (***) I have seen, somewhere, a recent authoritative statement which indicates much the same dates but about a year later.

    This is similar, at least -

    https://www.bbc.co.uk/news/technology-57186266">Farewell (again) to Microsoft's Internet Explorer</a>
    leading to
    https://blogs.windows.com/windowsexperience/2021/05/19/the-future-of-internet-explorer-on-windows-10-is-in-microsoft-edge/

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Arno Welzel@21:1/5 to All on Mon May 31 07:30:25 2021
    Thomas 'PointedEars' Lahn:

    Andrew Poulos wrote:

    On 24/05/2021 1:58 am, John Stockton wrote:
    I have not been able to access this newsgroup for a while.

    It shows :-D

    The following code was written in Firefox, and works there; it is called >>> in a script element which immediately follows <BODY>. it puts something
    like
    × FREDERIC.HTM - saved @ LCT 2021-05-22 Sat ×
    in the bottom right-hand corner of the window.

    But it does not work in Chrome, Vivaldi, Opera, AVG Secure Browser, or
    Edge.

    Of those, Chrome, Opera, _Avast_ Secure Browser, and Edge are now Chromium- based, i.e. use Blink as layout engine. Vivaldi is an attempt to preserve the original Opera’s Presto layout engine.

    Vivaldi is also based on Chromium:

    <https://vivaldi.com/blog/vivaldi-browser-vs-google-chrome/>



    --
    Arno Welzel
    https://arnowelzel.de

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From JJ@21:1/5 to Arno Welzel on Tue Jun 1 18:40:02 2021
    On Mon, 31 May 2021 07:30:25 +0200, Arno Welzel wrote:

    Vivaldi is also based on Chromium:

    <https://vivaldi.com/blog/vivaldi-browser-vs-google-chrome/>

    And it simply tries to resurrect only the Opera Presto's UI based features. Opera Presto's browser Actions, including JavaScript magic variable &
    function, won't be resurrected, because they requires modifying code deep in the internals of Chromium's layout engine. So far, there's no developer
    brave enough or bother to do that.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Thomas 'PointedEars' Lahn@21:1/5 to John Stockton on Mon Jun 7 03:05:33 2021
    Here we go again… :-(

    John Stockton wrote:

    On Monday, 24 May 2021 at 01:24:26 UTC+1, Thomas 'PointedEars' Lahn wrote (***) too much writing, with not enough thinking.

    FOAD.

    “Internet Explorer 11 follows the OS component lifecycle,[7] which means >> it remains supported with technical and security fixes while operating
    systems including it as a component are shipped. This means that there is
    no date for end of support for Internet Explorer 11.[8] On August 17,
    2020, Microsoft published a timeline indicating that the Microsoft Teams
    product would stop supporting Internet Explorer 11 on November 30, 2020,
    and Microsoft 365 products will end Internet Explorer 11 support on
    August 17, 2021.[9]”

    <https://en.wikipedia.org/wiki/Internet_Explorer_11>

    (***) I have seen, somewhere, a recent authoritative statement which indicates much the same dates but about a year later.

    Irrelevant unless there is evidence to support it. Eyewitness accounts
    are not considered evidence in (computer) science – something someone who is arrogant enough to post with their “Dr” in Usenet should be aware of.

    Compare: <https://github.com/airbnb/javascript>
    Any suggestions?

    I don't think you can set an element's style the way you are doing it.
    That is correct. “style” is historically a *read-only* *object*
    property[1], and has been FOR 20 YEARS NOW [2].

    Only as per the WHATWG DOM one may assign a string value to it, as a
    shorthand.[3]

    A backwards-compatible possibility would be to set the “style” attribute >> to that primitive string value. But it is better to append a stylesheet,
    and then format based on CSS class names.

    That

    Which of the THREE suggestions that I have made?

    had no effect - neither better nor worse.

    Learn to read. The effect that the latter has is to be backwards-
    compatible, and that changes the code for the better.

    “It works for me” is never a justification for a questionable practice. After more than two decades, haven’t we been over this /ad nauseam/ now?

    [Full quote]

    FOAD.

    ---- EOF -----

    (*** ...)

    "Rem acu non tetigisti" - as PGW might have written, but apparently did
    not (though a very few others did).

    FOAD.

    With the original code, most browsers tried would say something like
    // Uncaught TypeError: Failed to execute 'appendChild' on
    // 'Node': parameter 1 is not of type 'Node'.
    // at Show_Age (inc-cmmn.js:60)
    // at fred-set.htm:17

    from which I subsequently deduced that when createTextNode is fed with a non-string argument it (maybe an undefined one) returns a non-Node of
    disgust which fatally upsets appendChild.

    PEBKAC.

    Progress has been made.

    Evidently after 20 years you have not made any progress at all. Neither in your coding nor in your personality development. But I guess that’s too
    much to hope for at this point.

    --
    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.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Mark-@21:1/5 to Thomas 'PointedEars' Lahn on Mon Jun 7 02:13:12 2021
    Thomas 'PointedEars' Lahn wrote:

    Evidently after 20 years you have not made any progress at all.
    Neither in your coding nor in your personality development.


    You have the gall to refer to another's personality development.

    How little self-awareness you possess.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Andrew Poulos@21:1/5 to Mark- on Mon Jun 7 15:24:57 2021
    On 7/06/2021 12:13 pm, Mark- wrote:
    Thomas 'PointedEars' Lahn wrote:

    Evidently after 20 years you have not made any progress at all.
    Neither in your coding nor in your personality development.


    You have the gall to refer to another's personality development.

    How little self-awareness you possess.

    Doesn't your second statement negate your first?

    Andrew Poulos

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From The Natural Philosopher@21:1/5 to Thomas 'PointedEars' Lahn on Mon Jun 7 07:52:21 2021
    On 07/06/2021 02:05, Thomas 'PointedEars' Lahn wrote:
    “It works for me” is never a justification for a questionable practice.
    On the contrary, it is probably the *only* justification for *any* practice.

    We are all the descendants of people who found out 'what worked for them'

    There are no descendants of people who specialised in what didn't work
    for them


    After more than two decades, haven’t we been over this/ad nauseam/ now?


    Well yes., but nothing seems to shake your coincidence that

    - there is a right way and a wrong way
    - you are its sole custodian

    So I am sure that we have another two decades to come. Well you. I doubt
    that I do.


    --
    "When one man dies it's a tragedy. When thousands die it's statistics."

    Josef Stalin

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Arno Welzel@21:1/5 to All on Mon Jun 7 09:56:47 2021
    John Stockton:

    On Monday, 24 May 2021 at 01:24:26 UTC+1, Thomas 'PointedEars' Lahn wrote
    [...]
    Note:

    “Internet Explorer 11 follows the OS component lifecycle,[7] which means it
    remains supported with technical and security fixes while operating systems >> including it as a component are shipped. This means that there is no date
    for end of support for Internet Explorer 11.[8] On August 17, 2020,
    Microsoft published a timeline indicating that the Microsoft Teams product >> would stop supporting Internet Explorer 11 on November 30, 2020, and
    Microsoft 365 products will end Internet Explorer 11 support on August 17, >> 2021.[9]”

    <https://en.wikipedia.org/wiki/Internet_Explorer_11>



    (***) I have seen, somewhere, a recent authoritative statement which indicates much the same dates but about a year later.

    JFTR:

    <https://docs.microsoft.com/en-us/lifecycle/faq/internet-explorer-microsoft-edge>

    <https://docs.microsoft.com/en-us/lifecycle/announcements/internet-explorer-11-support-end-dates>


    --
    Arno Welzel
    https://arnowelzel.de

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Mark-@21:1/5 to Andrew Poulos on Mon Jun 7 12:15:27 2021
    Andrew Poulos wrote:

    On 7/06/2021 12:13 pm, Mark- wrote:
    Thomas 'PointedEars' Lahn wrote:

    Evidently after 20 years you have not made any progress at all.
    Neither in your coding nor in your personality development.


    You have the gall to refer to another's personality development.

    How little self-awareness you possess.

    Doesn't your second statement negate your first?

    Andrew Poulos

    No

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From John Harris@21:1/5 to Thomas 'PointedEars' Lahn on Mon Jun 7 18:18:10 2021
    On 07/06/2021 02:05, Thomas 'PointedEars' Lahn wrote:

    <snip>
    FOAD.

    Thomas Lahn wrote :

    "If you can't stand the heat, stay out of the kitchen."

    <snip>

    John

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Andrew Poulos@21:1/5 to Mark- on Tue Jun 8 07:35:55 2021
    On 7/06/2021 10:15 pm, Mark- wrote:
    Andrew Poulos wrote:

    On 7/06/2021 12:13 pm, Mark- wrote:
    Thomas 'PointedEars' Lahn wrote:

    Evidently after 20 years you have not made any progress at all.
    Neither in your coding nor in your personality development.


    You have the gall to refer to another's personality development.

    How little self-awareness you possess.

    Doesn't your second statement negate your first?


    No

    You're wrong, again.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Mark-@21:1/5 to Andrew Poulos on Tue Jun 8 12:33:37 2021
    Andrew Poulos wrote:

    On 7/06/2021 10:15 pm, Mark- wrote:
    Andrew Poulos wrote:

    On 7/06/2021 12:13 pm, Mark- wrote:
    Thomas 'PointedEars' Lahn wrote:

    Evidently after 20 years you have not made any progress at
    all. Neither in your coding nor in your personality
    development.


    You have the gall to refer to another's personality development.

    How little self-awareness you possess.

    Doesn't your second statement negate your first?


    No

    You're wrong, again.

    Such a delight to see ignorance on parade.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Andrew Poulos@21:1/5 to Mark- on Wed Jun 9 09:40:44 2021
    On 8/06/2021 10:33 pm, Mark- wrote:

    Such a delight to see ignorance on parade.

    Don't put yourself down. No doubt you're trying your best.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Mark-@21:1/5 to Andrew Poulos on Wed Jun 9 00:36:11 2021
    Andrew Poulos wrote:

    On 8/06/2021 10:33 pm, Mark- wrote:

    Such a delight to see ignorance on parade.

    Don't put yourself down. No doubt you're trying your best.


    You failed to grasp the concept of the two sentences I authored so
    attack the writer. A sign of ignorance.

    Your persistence is commendable at the cost of a wider and deeper
    display of...well ignorance.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Andrew Poulos@21:1/5 to Mark- on Wed Jun 9 13:14:57 2021
    On 9/06/2021 10:36 am, Mark- wrote:

    Such a delight to see ignorance on parade.

    Don't put yourself down. No doubt you're trying your best.

    You failed to grasp the concept of the two sentences I authored so
    attack the writer. A sign of ignorance.

    Self contradictory yet still claim someone else carries signs.

    Your persistence is commendable at the cost of a wider and deeper
    display of...well ignorance.

    Don't keep putting yourself down - that you don't know something is no
    cause for shame.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Mark-@21:1/5 to Andrew Poulos on Wed Jun 9 03:27:25 2021
    Andrew Poulos wrote:


    Self contradictory yet still claim someone else carries signs.

    You have one or more misunderstood words in the original two sentences
    I wrote.

    Time to move on. Good luck.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Andrew Poulos@21:1/5 to Mark- on Wed Jun 9 20:57:59 2021
    On 9/06/2021 1:27 pm, Mark- wrote:

    You have one or more misunderstood words in the original two sentences
    I wrote.

    So how did I manage to put words into sentences *you* wrote?

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)