Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums JavaScript Why does my one link at CodePen just loads to a white page?

  • This topic is empty.
Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #262545
    wost
    Participant

    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/

    #262566
    Shikkediel
    Participant

    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)
  • The forum ‘JavaScript’ is closed to new topics and replies.