1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

Help with onClick - Not working in IE

Discussion in 'JavaScript' started by FPForum, Feb 22, 2014.

  1. #1
    I have the following code..for some reason the onClick portion does not work in IE. Any idea how this can be fixed?

    
      if ( $.cookie("fb-lk") && $.cookie("fb-sh") ) {
      $("#multistep-proceed").fadeTo(300, 1).prop("disabled", false).attr("onClick", "loadGTW()");
      }
      } multistep_check();
    
      function loadGTW () {
      window.open('https://www.mywebsite.com', '_top')
      }
    
    Code (markup):

     
    FPForum, Feb 22, 2014 IP
  2. loop

    loop Active Member

    Messages:
    519
    Likes Received:
    4
    Best Answers:
    1
    Trophy Points:
    90
    #2
    maybe IE popup blocker, not allow it?
     
    loop, Mar 4, 2014 IP
  3. HuggyStudios

    HuggyStudios Well-Known Member

    Messages:
    724
    Likes Received:
    20
    Best Answers:
    26
    Trophy Points:
    165
    #3
    Which jQuery version are you using? jQuery 2+ doesn't support older versions of IE.
     
    HuggyStudios, Mar 5, 2014 IP
  4. deathshadow

    deathshadow Acclaimed Member

    Messages:
    9,732
    Likes Received:
    1,998
    Best Answers:
    253
    Trophy Points:
    515
    #4
    attr("onClick", "loadGTW()")

    are you sure the function name should be in quotes? (not a big jq fan, if that is how it should be just another strike against JQ)

    Also, shouldn't the function be declared BEFORE you try and reference it?
     
    deathshadow, Mar 5, 2014 IP
  5. PoPSiCLe

    PoPSiCLe Illustrious Member

    Messages:
    4,623
    Likes Received:
    725
    Best Answers:
    152
    Trophy Points:
    470
    #5
    Can't you just redo it to use .on() instead of .attr()?
    Something like: .on('click', loadGTW()); ?
    And @deathshadow - as long as he's running it inside the $(document).ready()-container, jQuery waits and reads all before doing anything, hence the function can be declared after the actual $(document).ready() - however, if the function itself is declared within the $(document).ready() container, it should be declared before, indeed.
     
    PoPSiCLe, Mar 7, 2014 IP
  6. deathshadow

    deathshadow Acclaimed Member

    Messages:
    9,732
    Likes Received:
    1,998
    Best Answers:
    253
    Trophy Points:
    515
    #6
    ... and say hello to another reason I'd never use the fat bloated idiotic halfwit BS known as jQuery in the first place... Of course the whole 'ready' nonsense just overcomplicates something simple... like just loading the file right before </body> so the DOM is built and you don't even have to wait for 'ready'?
     
    deathshadow, Mar 8, 2014 IP
  7. PoPSiCLe

    PoPSiCLe Illustrious Member

    Messages:
    4,623
    Likes Received:
    725
    Best Answers:
    152
    Trophy Points:
    470
    #7
    That is also perfectly possible - it's just that jQuery provides a way to have the js wait for the loading of the page, without having to add the js to the end of the code. Stupid? Perhaps.
     
    PoPSiCLe, Mar 10, 2014 IP