1

I am adding html/javascript to shogun app on shopify. I copied this from a youtube video because shogun doesn't offer this functionality. I am not a coder, just dabble in it. It says missing semi-colon but I can't find it.

It should be a dropdown menu that goes directly to a website. Can you help. See code

<!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>
azerica
  • 11
  • 1

1 Answers1

2

Maybe it's because of the misspelling and the syntax error in your code. See below code that has been modified a bit:

<!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>
GSP KS
  • 1,783
  • 2
  • 5
  • 9
  • it was the misspelling. someone above caught that too. I swear I looked at it a million times. Now it works but I won't open up the window it says "pop up blocked" I hope the users don't get that each time they click. Do you know anything about that? – azerica May 25 '20 at 03:28
  • @azerica I think it is caused by a browser for security reasons. If you're using chrome this [link](https://support.google.com/chrome/answer/95472?co=GENIE.Platform%3DDesktop&hl=en) might help. For firefox visit [here](https://support.mozilla.org/en-US/kb/pop-blocker-settings-exceptions-troubleshooting). I hope that helps. – GSP KS May 25 '20 at 03:50
  • yeah it's something else weird. the way it's coded as a pop up instead of just opening a link is making the pop up blocker kick in. I had several people try it. – azerica May 25 '20 at 16:01
  • @azerica If you want to just redirect to a URL or open a URL in a new tab, see the updated answer. – GSP KS May 26 '20 at 02:06