If Statement not working with And(&&)Operator [英] If Statement not working with And (&&) Operator
问题描述
我有一个很难写出似乎应该是一个简单的if语句!我需要它说如果mod不等于a,b或c - 然后这样做。这是我正在尝试,但未成功:
I'm having a hard time writing up what seems should be a simple if statement! I need it to say if mod does not equal a, b, or c - then do this. Here is what I was trying but have been unsuccessful:
var mod = CURRENT_MODULE_ID;
if (mod != "5827289" && mod != "5195103" && mod != "5181422") {
doSomething();
}
当我在编辑器中输入时, 实体名称必须紧跟在实体引用中的'&'后面。
..并且在我去测试时不工作。
When I type this into my editor it says there is an error, specifically that "The entity name must immediately follow the '&' in the entity reference." .. and is not working when I go to test.
任何帮助都很感激!
更新:
网址:esber.squarespace.com
UPDATE: The url: esber.squarespace.com
完整脚本:
<script type="text/javascript" src="/storage/scripts/sessvars.js"></script>
<script type="text/javascript">
<![CDATA[
onload=function(){
sessvars.browserConfirmation?'none':'';
sessvars.ageConfirmation?'none':'';
};
var mod = Squarespace.Constants.CURRENT_MODULE_ID;
if (mod != "5827289" && mod != "5195103" && mod != "5181422") {
if(sessvars.ageConfirmation != "yes"){
window.location = "/verify/";
};
};
]]>
</script>
我想让网站中的每个网页在加载到网页时自动重定向到验证页,除非验证页(/ verify),您未验证页(/未验证)或登录页(/ login) - 除非用户已通过设置sessvar进行验证,否则他们可以继续首页。
I want every page in the site to automatically redirect on page load to the verify page, unless it is the verify page (/verify), the "You are not verified" page (/not-verified), or the login page (/login) -- unless the user already verified by setting the sessvars, then they can continue on to the homepage.
要测试这个,我去esber.squarespace.com并点击右边的菜单项(这个菜单最终会被隐藏与页面) - 当我尝试去另一个页面,而不验证我的年龄首先,我应该重定向回到/验证页面,但是没有发生。
To test this I go to esber.squarespace.com and click on one the menu items at the right (this menu would eventually be hidden when I'm done with the page) -- when i try to go to another page without veriying my age first i should be redirected back to the /verify page but that isnt happening.
如果我将脚本修改为:
<script type="text/javascript" src="/storage/scripts/sessvars.js"></script>
<script type="text/javascript">
onload=function(){
sessvars.browserConfirmation?'none':'';
sessvars.ageConfirmation?'none':'';
};
var mod = Squarespace.Constants.CURRENT_MODULE_ID;
if (mod != "5827289") {
if(sessvars.ageConfirmation != "yes"){
window.location = "/verify/";
};
};
</script>
那么它工作正常(?)
推荐答案
尝试以下操作:
// <![CDATA[
onload=function(){
sessvars.browserConfirmation?'none':'';
sessvars.ageConfirmation?'none':'';
};
var mod = Squarespace.Constants.CURRENT_MODULE_ID;
if (mod != "5827289" && mod != "5195103" && mod != "5181422") {
if(sessvars.ageConfirmation != "yes"){
window.location = "/verify/";
};
};
// ]]>
如果这不起作用,只需将代码留在那里,以便我们可以调试它直接在您的网站上
If this doesn't work, just leave the code there for a bit, so that we can debug it directly on your website
这篇关于If Statement not working with And(&&)Operator的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!