Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. JavaScript
  4. Popup div

Popup div

Scheduled Pinned Locked Moved JavaScript
javascripthtml
7 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • O Offline
    O Offline
    Otekpo Emmanuel
    wrote on last edited by
    #1

    Good day friends! I am working on a site and in this site there is HTML link. On click event of the link am calling JavaScript function which is running fine. but when I specify the href of the link the JS function is discarded.

    M A Z 3 Replies Last reply
    0
    • O Otekpo Emmanuel

      Good day friends! I am working on a site and in this site there is HTML link. On click event of the link am calling JavaScript function which is running fine. but when I specify the href of the link the JS function is discarded.

      M Offline
      M Offline
      Midi_Mick
      wrote on last edited by
      #2

      The onClick event needs to return true to enable the default action of the tag.

      Cheers, Mick ------------------------------------------------ It doesn't matter how often or hard you fall on your arse, eventually you'll roll over and land on your feet.

      1 Reply Last reply
      0
      • O Otekpo Emmanuel

        Good day friends! I am working on a site and in this site there is HTML link. On click event of the link am calling JavaScript function which is running fine. but when I specify the href of the link the JS function is discarded.

        A Offline
        A Offline
        Afzaal Ahmad Zeeshan
        wrote on last edited by
        #3

        There might be an exception, check your console for errors. F12 for development tools and then check Console for any messages. Also, use event.preventDefault() to stop the browser from navigating away upon click on the link,

        function onclickhandler() {
        event.preventDefault();

        // rest of the code here.
        }

        This will do what you need.

        The shit I complain about It's like there ain't a cloud in the sky and it's raining out - Eminem ~! Firewall !~

        O 1 Reply Last reply
        0
        • A Afzaal Ahmad Zeeshan

          There might be an exception, check your console for errors. F12 for development tools and then check Console for any messages. Also, use event.preventDefault() to stop the browser from navigating away upon click on the link,

          function onclickhandler() {
          event.preventDefault();

          // rest of the code here.
          }

          This will do what you need.

          The shit I complain about It's like there ain't a cloud in the sky and it's raining out - Eminem ~! Firewall !~

          O Offline
          O Offline
          Otekpo Emmanuel
          wrote on last edited by
          #4

          thanks for the reply. the link button is Compose. what if person click on Inbox link and from Inbox page click on Compose link? For sure the person will be redirected to Compose page but the popup div appears and disappear after complete load of the page. Any help please.

          A 1 Reply Last reply
          0
          • O Otekpo Emmanuel

            thanks for the reply. the link button is Compose. what if person click on Inbox link and from Inbox page click on Compose link? For sure the person will be redirected to Compose page but the popup div appears and disappear after complete load of the page. Any help please.

            A Offline
            A Offline
            Afzaal Ahmad Zeeshan
            wrote on last edited by
            #5

            Then, in such cases if you only want to dynamically update the content instead of having to manage events, I recommend using Single-page applications. If not, then use my suggestion, that was the answer to disable the browser from navigating to that link itself, you can run the logic as needed.

            The shit I complain about It's like there ain't a cloud in the sky and it's raining out - Eminem ~! Firewall !~

            1 Reply Last reply
            0
            • O Otekpo Emmanuel

              Good day friends! I am working on a site and in this site there is HTML link. On click event of the link am calling JavaScript function which is running fine. but when I specify the href of the link the JS function is discarded.

              Z Offline
              Z Offline
              ZurdoDev
              wrote on last edited by
              #6

              How are we supposed to know what is happening without being able to see anything?

              There are two kinds of people in the world: those who can extrapolate from incomplete data. There are only 10 types of people in the world, those who understand binary and those who don't.

              Z 1 Reply Last reply
              0
              • Z ZurdoDev

                How are we supposed to know what is happening without being able to see anything?

                There are two kinds of people in the world: those who can extrapolate from incomplete data. There are only 10 types of people in the world, those who understand binary and those who don't.

                Z Offline
                Z Offline
                ZurdoDev
                wrote on last edited by
                #7

                Magic!

                There are two kinds of people in the world: those who can extrapolate from incomplete data. There are only 10 types of people in the world, those who understand binary and those who don't.

                1 Reply Last reply
                0
                Reply
                • Reply as topic
                Log in to reply
                • Oldest to Newest
                • Newest to Oldest
                • Most Votes


                • Login

                • Don't have an account? Register

                • Login or register to search.
                • First post
                  Last post
                0
                • Categories
                • Recent
                • Tags
                • Popular
                • World
                • Users
                • Groups