1

我正在将 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>
4

1 回答 1

2

可能是因为代码中的拼写错误和语法错误。请参阅以下已修改的代码:

<!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>

于 2020-05-25T03:06:41.533 回答