0
Follow
0
View

Images not loading from different website in Safari HTML/JavaScript

ofhzxzg 注册会员
2023-01-25 17:36

So removing some stuff worked for me. Basically Safari doesn't support navigator.userAgentData so it wasn't displaying images for that reason. So i had to remove it:

for (let i = 0; i < 11; i++) {
  Draw_Images(i);
}

function Draw_Images(i) {
  const isMobile = navigator.userAgentData.mobile;   //REMOVED THIS AND IT WORKED!!
  var div = document.createElement('div');
  div.id = "meme" + i;
  div.style.borderRadius = "1%";
  div.style.width = "200px";
  div.style.height = "200px";
  div.style.border = "1px solid";
  div.style.padding = "0";
  div.style.margin = "0";
  var divParent = document.getElementById("memes_container").appendChild(div);
  var img = new Image();
  img.src = "https://iynmemes.netlify.app/images_memes/meme" + i + ".jpg";
  img.id = "image_meme" + i;
  img.style.width = "100%";
  img.style.height = "100%";
  img.style.objectFit = "contain";
  img.className = "img-fluid";
  img.alt = i;
  img.crossOrigin = 'anonymous';
  divParent.appendChild(img);
}

About the Author

Question Info

Publish Time
2023-01-25 17:36
Update Time
2023-01-25 17:36