Click here to Skip to main content
15,878,852 members
Home / Discussions / JavaScript
   

JavaScript

 
QuestionSecond chart not react to data entered, why? Explain, please, how to solve the issue? Pin
Earl Lembertas27-Sep-22 10:35
Earl Lembertas27-Sep-22 10:35 
AnswerRe: Second chart not react to data entered, why? Explain, please, how to solve the issue? Pin
Pete O'Hanlon27-Sep-22 20:46
mvePete O'Hanlon27-Sep-22 20:46 
GeneralRe: Second chart not react to data entered, why? Explain, please, how to solve the issue? Pin
Earl Lembertas28-Sep-22 0:00
Earl Lembertas28-Sep-22 0:00 
GeneralRe: Second chart not react to data entered, why? Explain, please, how to solve the issue? Pin
Pete O'Hanlon28-Sep-22 4:26
mvePete O'Hanlon28-Sep-22 4:26 
QuestionWhy doesn't this script work as expected? Pin
DSB Audio (David Sweeney-Bear)24-Sep-22 3:39
DSB Audio (David Sweeney-Bear)24-Sep-22 3:39 
AnswerRe: Why doesn't this script work as expected? Pin
DSB Audio (David Sweeney-Bear)24-Sep-22 7:43
DSB Audio (David Sweeney-Bear)24-Sep-22 7:43 
AnswerRe: Why doesn't this script work as expected? Pin
Richard Deeming25-Sep-22 21:42
mveRichard Deeming25-Sep-22 21:42 
GeneralRe: Why doesn't this script work as expected? Pin
DSB Audio (David Sweeney-Bear)30-Sep-22 4:16
DSB Audio (David Sweeney-Bear)30-Sep-22 4:16 
Thanks, I got there in the end, although I had to modify things quite a bit to implement it in my Wordpress site:
let backgroundElement = document.querySelector('.site-container');
    const positionXY = [16, 32, 48, 64, 80, 99, 66.6, 33.3, 1, 15, 30, 50, 75];
    let storedXY = sessionStorage.getItem('writeXY'); let lastXY = JSON.parse(storedXY);
if (storedXY == null) {
    let randomX = positionXY[Math.floor(Math.random() * positionXY.length)];
    let randomY = positionXY[Math.floor(Math.random() * positionXY.length)];
document.querySelector('.site-container').style.cssText = `background-position: ${randomX}% ${randomY}%; background-size: auto;`
    let randomXY = [randomX, randomY]
    sessionStorage.setItem('writeXY', JSON.stringify(randomXY));
}
else if (storedXY !== null) {
    let randomX = positionXY[Math.floor(Math.random() * positionXY.length)];
    let randomY = positionXY[Math.floor(Math.random() * positionXY.length)];
    let testX = Math.abs(randomX-lastXY[0]);
    let testY = Math.abs(randomY-lastXY[1]);
    let randomXY = [randomX, randomY]
    sessionStorage.setItem('writeXY', JSON.stringify(randomXY));
      while (testX < 16 || testY < 16) {
        randomX = positionXY[Math.floor(Math.random() * positionXY.length)];
        randomY = positionXY[Math.floor(Math.random() * positionXY.length)];
        testX = Math.abs(randomX-lastXY[0]);
        testY = Math.abs(randomY-lastXY[1]);
      }
document.querySelector('.site-container').style.cssText = `background-position: ${randomX}% ${randomY}%; background-size: auto;`
        randomXY = [randomX, randomY]
        sessionStorage.setItem('writeXY', JSON.stringify(randomXY));

I dispensed with the onClick event in favour of pageLoad since within the WP structure, each link is a new page.

Therefore, didn't need to exclude certain anchor links, but did find that using 'a: not(".class-name")' worked to exclude links that I assigned a particular classname to.
GeneralRe: Why doesn't this script work as expected? Pin
DSB Audio (David Sweeney-Bear)30-Sep-22 4:31
DSB Audio (David Sweeney-Bear)30-Sep-22 4:31 
AnswerRe: Why doesn't this script work as expected? Pin
Jeremy Falcon26-Oct-22 11:36
professionalJeremy Falcon26-Oct-22 11:36 
QuestionCan sending a large number of requests to the server cause any performance issues on the server? Pin
Alex Wright 202221-Sep-22 8:33
Alex Wright 202221-Sep-22 8:33 
AnswerRe: Can sending a large number of requests to the server cause any performance issues on the server? Pin
Richard Deeming21-Sep-22 21:40
mveRichard Deeming21-Sep-22 21:40 
QuestionMultiple popup windows - information is the same in all of them Pin
BartekDD21-Sep-22 2:02
BartekDD21-Sep-22 2:02 
QuestionOne big collection or nested collections Pin
waldette 202214-Sep-22 11:35
waldette 202214-Sep-22 11:35 
AnswerRe: One big collection or nested collections Pin
Pete O'Hanlon14-Sep-22 20:54
mvePete O'Hanlon14-Sep-22 20:54 
GeneralRe: One big collection or nested collections Pin
waldette 202215-Sep-22 6:13
waldette 202215-Sep-22 6:13 
QuestionPinch zoom in zoom out in js Pin
madhuri jawadekar11-Sep-22 20:01
madhuri jawadekar11-Sep-22 20:01 
Questionhow to make campaign windows Pin
Member 157551811-Sep-22 20:22
Member 157551811-Sep-22 20:22 
AnswerRe: how to make campaign windows Pin
Richard MacCutchan1-Sep-22 22:02
mveRichard MacCutchan1-Sep-22 22:02 
AnswerRe: how to make campaign windows Pin
Dave Kreskowiak2-Sep-22 12:56
mveDave Kreskowiak2-Sep-22 12:56 
QuestionIs there a way to input a unique number for each array output? Pin
machinewraith31-Aug-22 15:46
machinewraith31-Aug-22 15:46 
AnswerRe: Is there a way to input a unique number for each array output? Pin
Richard Deeming1-Sep-22 22:23
mveRichard Deeming1-Sep-22 22:23 
Questionjavascript looping pattern question Pin
ravindra Yadav 202213-Aug-22 1:22
ravindra Yadav 202213-Aug-22 1:22 
AnswerRe: javascript looping pattern question Pin
Richard MacCutchan13-Aug-22 1:31
mveRichard MacCutchan13-Aug-22 1:31 
QuestionJavascript Pin
User 1567076229-Jul-22 0:20
User 1567076229-Jul-22 0:20 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.