基本上我有一个变量可以使用它提供某个图像 $member_profile_image 的 url。我正在尝试检查该网址,然后在其中找到“默认”一词。我已经这样做了,indexOf 显示为 22。这让我知道有人没有将照片上传到他们的个人资料中。如果他们没有上传个人资料照片,我希望他们只能访问我存储在数组 myurls 中的链接。因此,如果上传 indexOf 确实为 22,并且它们位于存储在 myurls 中的其中一个页面上,我根本不希望发生任何事情,但是如果他们尝试转到任何其他页面,我希望将其重定向到该页面上传一张照片。我对这一切都很陌生,所以我可能离这里很远。到目前为止,我唯一能做的就是重定向到上传照片的页面,但它会一遍又一遍地重新加载页面。下面的代码:
<script>
var image = "$member_profile_image"
var upload = image.indexOf("Default");
var myurls = new Array(3);
myurls[0] = "http://websiteforyou.spruz.com/?page=login&cmd=c&id=7394750B-F821-48B6-B6AC-1508D1932390&c=eb3hb4el98";
myurls[1] = "http://www.websiteforyou.spruz.com/?page=login&cmd=confirm";
myurls[2] = "http://www.websiteforyou.spruz.com";
myurls[3] = "http://www.websiteforyou.spruz.com/member/?page=settings&cmd=personal";
if(myurls[0,1,2] = window.location && upload == "22")
alert("have a great day");
else
alert("You have to upload a profile image to participate on this site");
window.location.replace("http://www.websiteforyou.spruz.com/member/?page=settings&cmd=personal");
</script>