0

I tray to make a static page on github page. I use this code to load the images:

function createDeck(call) {
    let deck = [];
    let jarOfPromise = [];
    for (let x of ["B", "C", "S", "D"]) {
        for (let y of [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13]) {
            jarOfPromise.push(
                new Promise(resolve => {
                    let tempCard = new Card(y, x); // create card with value and seed
                    
                    tempCard.imgCard.addEventListener('load',
                        function () {
                            resolve(true);
                        });
                    tempCard.imgCard.setAttribute('crossOrigin', 'same-origin');
                    tempCard.imgCard.src = createImgFileName(y, x);
                    deck.push(tempCard);
                })
            );
        }
    }

    Promise.all(jarOfPromise).then(_ => {
        call(deck);
    });
}

function createImgFileName(val, seed, dir = "cardsImg") {
    return "../" + dir + "/" + val.toString() + seed + ".jpg"
    // example "../cardsImg/1B.jpg"
}

but when a load the page I have a strict-origin-when-cross-origin`

This is my project:

https://github.com/Clingonboy/foraccio-0.1.0

When I try the some project on my computer with live-server it works.

I search about this problem but I could not find information to understand where is my mistake.

1 Answers1

1

Your images just cannot be found

Change this

"../" + dir + "/" + val.toString() + seed + ".jpg"

To this

"./" + dir + "/" + val.toString() + seed + ".jpg"
Konrad
  • 21,590
  • 4
  • 28
  • 64