javascript - 我是一个非常新的编码器,它说缺少分号
问题描述
我正在将 html/javascript 添加到 shopify 上的 shogun 应用程序。我从 youtube 视频中复制了这个,因为 shogun 不提供此功能。我不是编码员,只是涉足它。它说缺少分号,但我找不到。
它应该是一个直接进入网站的下拉菜单。你能帮我吗。查看代码
<!doctype html>
<html lang="en">
<head>
<title>Choose your current brand</title>
</head>
<body>
<h1> this is where the header 1 tag goes</h1>
<form name="competitor brands">
<select name="Brand" id="Brand">
<option value="nothing" seleted="selected">Select a Brand </option>
<option value="https://www.goodhousekeeping.com/life/pets/g4531/cutest-dog-breeds/">Active Wow</option>
<option value="https://www.goodhousekeeping.com/life/pets/g4531/cutest-dog-breeds/">Brand 2</option>
<option value="https://www.goodhousekeeping.com/life/pets/g4531/cutest-dog-breeds/">Brand 3</option>
<option value="https://www.goodhousekeeping.com/life/pets/g4531/cutest-dog-breeds/">Brand 4</option>
<option value="https://www.goodhousekeeping.com/life/pets/g4531/cutest-dog-breeds/">Brand 5</option>
</select>
</form>
<script type="text/javascript">
var urlMenu = document.getElementById ('Brand');
urlMenu.onchange = function() {
var userOption = this.options[this.selectedIndex];
if (userOption.value !=-"nothing") {
windwow.open (userOption.value, "Competitor Brand Ingredients","");
}
}
</script>
</body>
</html>
解决方案
可能是因为代码中的拼写错误和语法错误。请参阅以下已修改的代码:
<!doctype html>
<html lang="en">
<head>
<title>Choose your current brand</title>
</head>
<body>
<h1> this is where the header 1 tag goes</h1>
<form name="competitor brands">
<select name="Brand" id="Brand">
<option value="nothing" seleted="selected">Select a Brand </option>
<option value="https://www.goodhousekeeping.com/life/pets/g4531/cutest-dog-breeds/">Active Wow</option>
<option value="https://www.goodhousekeeping.com/life/pets/g4531/cutest-dog-breeds/">Brand 2</option>
<option value="https://www.goodhousekeeping.com/life/pets/g4531/cutest-dog-breeds/">Brand 3</option>
<option value="https://www.goodhousekeeping.com/life/pets/g4531/cutest-dog-breeds/">Brand 4</option>
<option value="https://www.goodhousekeeping.com/life/pets/g4531/cutest-dog-breeds/">Brand 5</option>
</select>
</form>
<script type="text/javascript">
var urlMenu = document.getElementById ('Brand');
urlMenu.onchange = function() {
var userOption = this.options[this.selectedIndex];
if (userOption.value !== "nothing") { //BEFORE: if (userOption.value !=-"nothing") {
window.open (userOption.value, "Competitor Brand Ingredients",""); //BEFORE: windwow.open (userOption.value, "Competitor Brand Ingredients","");
// To just redirect to the URL:
// window.open (userOption.value);
// To open the URL in a new tab:
// window.open (userOption.value, '_blank');
}
}
</script>
</body>
</html>
推荐阅读
- openxml - 从行中获取 WorkbookPart
- python - dockerizing 应用程序后无法访问烧瓶端点
- javascript - 从标签中挑出 href="" 并通过 javascript 更改它
- javascript - 如何正确地将代码包装在函数中?
- c - while循环中的奇怪输出(C语言)
- python - 是否可以总结解释器初始化步骤?
- php - PHP 在某个日期前 48 小时自动执行某项操作
- r - 从列选择中列出行
- java - 关于 Servlet 绑定模式和默认 Servlet
- azure-service-fabric - 补丁编排应用程序 (POA) 不在 gMSA 安全集群中安装更新