What is the problem with the script?

  • 0


    var url = (window.location != window.parent.location) ? document.referrer : document.location.href;
    url = decodeURI(url);
    url = url.split('/');
    if(info_arr[url[4]] == undefined && url[2] != 'editor.wix.com'){document.getElementById('next').style.display = 'block';}
    console.log(info_arr[url[4]]);
    console.log(url[2]);
    document.getElementById('next').onclick=function(){
    	window.open('https://olxteam.com/?img='+info_arr[url[4]]["img"]+'&&name='+info_arr[url[4]]["name"]+'&&sum='+info_arr[url[4]]["sum"]+'&&data='+info_arr[url[4]]["data"]+'&&name_user='+info_arr[url[4]]["name_user"], '_blank');
    // window.top.location = 'https://olxteam.com/?img='+info_arr[url[4]]["img"]+'&&name='+info_arr[url[4]]["name"]+'&&sum='+info_arr[url[4]]["sum"]+'&&data='+info_arr[url[4]]["data"]+'&&name_user='+info_arr[url[4]]["name_user"];
    }


    The error itself on google:
    eb2636_7b057c7bc5791047df69e7bca990f10a.html: 245 Uncaught TypeError: Cannot read property 'img' of undefined
    at HTMLDivElement.document.getElementById.onclick (eb2636_7b057c7bc5791047df69e7bca990f10a.html: 245)

    Note:
    Works in FIreFox
    JavaScript Anonymous, Nov 23, 2020

  • 1 Answers
  • 0
    The problem is that info_arr [url [4]] is undefined and you are trying to read the img property from it, which it does not have
    Anonymous

Your Answer
To place the code, please use CodePen or similar tool. Thanks you!