簡體   English   中英

href 鏈接到 js 並驗證用戶的個人資料以訪問 url

[英]href link to js and validate user's profile to visit url

我有 html href 並鏈接到 js 文件中的函數。 從用戶單擊時的 html 中,它將按國家/地區驗證用戶的個人資料。 如果用戶的配置文件= TH 和 SG,它將打開一個 url,否則它將打開 b url。 請幫我。 我不知道我的代碼有什么問題

 /* API Completion */ api.done(function (a, c, d) { console.log(ad); var countryCode = ""; function checkCountry(upp) { return upp.Key === "CountryCode"; } var arrUPP = adUserProfileProperties.results.filter(checkCountry); //btn.addEventListener("click", travel); $(document).ready(function() { //$('ul.nav li').click(function() if (arrUPP.length > 0 && arrUPP[0].Value) { countryCode = arrUPP[0].Value; } else if (countryCode == "TH" && countryCode == "SG") { window.location.href = 'https://....a url'; } else { window.location.href = 'https://....b url'; return; } }); //} }); api.fail(function (a, b, c) { var errorMessage = []; errorMessage.push(errorMessage); errorMessage.push("Error: " + a.responseJSON.error.message.value); alert(errorMessage.join("\n")); });
 <li class="main"> <a class="travel" href="javascript:travel();" target="blank"> <i class="icon-travel"></i> <span>Country</span> </a> </li>

這永遠不會是真的countryCode == "TH" && countryCode == "SG" 您期望一個值既是“TH”又是“SG”。 您可能打算使用|| .

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM