Jump to content

markeizer

Members
  • Posts

    4
  • Joined

  • Last visited

Everything posted by markeizer

  1. Hi there, I'm back with one that would again considered a pretty obvious question. I hope not to be too annoying but, on the other hand, I guess it will be easy for you to address this little problem. Let's say I have a link with id="goo" and I want it to be opened in another tab and leave the current tab unchanged (kinda like doing right click -> open in new tab). And I want to use listeners not handlers. So that's my code so far: var linkEst ={ init:function() { var link = document.getElementById("goo") if(typeof link.addEventListener != "undefined") { link.addEventListener("click", linkEst.oTab, false) } else if (typeof link.attachEvent != "undefined") { link.attachEvent("onclick", linkEst.oTab) } }, oTab:function(event) { if(typeof event == "undefined") { event = window.event } if(typeof event.preventDefault != "undefined") { open(this.href) event.preventDefault() } else { open(this.href) event.returnValue = false } }}linkEst.init() Works like a charm in FF, but messes up in IE. IE pops an error: "can't find /path/to/undefined". As soon as I click ok he then follows the link (in the same tab). So I assume that in IE's case, this is not pointing to the actual address, or is the error somewhere else? As always, thanks in advance for any kind of help or suggestion. I know I can find snippets to achieve the same result, but I'm trying to learn as best as I can.
  2. Oh yes thanks that was more of a typo, will modify accordingly. As for your first sentence, what do you mean by accurate?
  3. I'm sorry if, to many of you, this would seem like an obvious question, but I haven't been able to find a satisfying answer yet. Consider this piece of code; <button onclick="myFunction()"> Type A<button onclick="function(){myFunction()}"> Type B The first one calles the function, the second calls a function that, inside it, calles myFunction. I have notices sometimes type A and B both work, sometimes only one of them works, but I haven't been able to understand why exactly. Also applicable to: var x = document.getElementById("example")x.onclick=myFunction()var x = document.getElementById("example")x.onclick=function(){myFunction()} Can someone point out the differences for me? Would be very appreciated, I'm kinda stuck on this. Thanks in advance.
×
×
  • Create New...