Forums

Give help. Get help.

  • # November 14, 2017 at 2:58 pm

    I tried adding some simple JS functionality to my page at CodePen, but I just can’t seem to get past this one problem: the one link in my CodePen-page just goes to a white page for some reason. I have no idea why this even happens. I tried adding preventDefault(), but that didn’t work either.

    What have I done wrong? All my other links goes to nothing, as they should. It’s just this one link in my mobile layout. Not even the console log works, strangely enough.
    Codepen: https://codepen.io/wostensen/pen/jarJVB/

    # November 14, 2017 at 8:08 pm

    It’s because the element also has an inline event inside the HTML itself:

    onclick="open();"
    

    https://www.w3schools.com/jsref/met_win_open.asp

    Binding events directly precedes the addEventListener method:

    codepen.io/anon/pen/eeEVBG

    So that’ll work despite the inline event (it overwrites it).

Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.

icon-anchoricon-closeicon-emailicon-linkicon-logo-staricon-menuicon-nav-guideicon-searchicon-staricon-tag