Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.javascript > #40100 > unrolled thread
| Started by | John Stockton <dr.j.r.stockton@gmail.com> |
|---|---|
| First post | 2021-05-23 08:58 -0700 |
| Last post | 2021-05-24 07:47 +1000 |
| Articles | 2 — 2 participants |
Back to article view | Back to comp.lang.javascript
Browser-dependent JavaScript problem John Stockton <dr.j.r.stockton@gmail.com> - 2021-05-23 08:58 -0700
Re: Browser-dependent JavaScript problem Andrew Poulos <ap_prog@hotmail.com> - 2021-05-24 07:47 +1000
| From | John Stockton <dr.j.r.stockton@gmail.com> |
|---|---|
| Date | 2021-05-23 08:58 -0700 |
| Subject | Browser-dependent JavaScript problem |
| Message-ID | <c759d589-5290-4bfb-b3bd-588c6799fb11n@googlegroups.com> |
I have not been able to access this newsgroup for a while.
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.
In IE11, the style setting has no effect, and the unadorned string appears top right. OS is Windows 10.
The style line will probably be wrapped in transmission.
For test purposes, replace YMDDstr with toString or remove .YMDDstr() !
NPR means NON-PRINT -
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) }
Any suggestions?
--
(c) John Stockton, near London, UK. Using Google Groups. |
Mail: J.R.""""""""@physics.org - or as Reply-To, if any. |
[toc] | [next] | [standalone]
| From | Andrew Poulos <ap_prog@hotmail.com> |
|---|---|
| Date | 2021-05-24 07:47 +1000 |
| Message-ID | <S6ydnT4TC6L8UDf9nZ2dnUU7-L_NnZ2d@westnet.com.au> |
| In reply to | #40100 |
On 24/05/2021 1:58 am, John Stockton wrote:
> I have not been able to access this newsgroup for a while.
>
>
> 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.
> In IE11, the style setting has no effect, and the unadorned string appears top right. OS is Windows 10.
>
> The style line will probably be wrapped in transmission.
> For test purposes, replace YMDDstr with toString or remove .YMDDstr() !
> NPR means NON-PRINT -
>
>
> 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) }
>
> Any suggestions?
I don't think you can set an element's style the way you are doing it.
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;
}
}
Andrew Poulos
[toc] | [prev] | [standalone]
Back to top | Article view | comp.lang.javascript
csiph-web