Open a new window on click and new tab on right click of a home page layout link.

I managed to open a new window with following syntax.

window.open(url, mywindowName, height="200", width="400");

But I am finding difficult in opening a new tab because when i right click I didnot find the open new window activce in popup.

Any help or Ideas are appriciated.

  • 1
    Javascript provides a way to detect if right or left button on the mouse is clicked. You can listen to the click event and then you take action based on that. But you will have to write a script in a file, store it in the static resource and then reference it in the custom link using the {!REQUIRESCRIPT('\resource\yourjsfile')}, this is because if you add the script direclty in the link it will get executed only when clicked but you would want to listen to events before the click happens. Check out : quirksmode.org/js/events_properties.html
    – Sam
    Apr 20, 2015 at 16:00
  • @ theGreatDanton Yes I noticed that it is not listening to the events. From the link you provided I am writing this code to the javascript file and uploading to the static resource and refering that file. correct me from here code I am going to put in the filei is just this method function doSomething(e) { var rightclick; if (!e) var e = window.event; if (e.which) rightclick = (e.which == 3); else if (e.button) rightclick = (e.button == 2); alert('Rightclick: ' + rightclick); // true or false } and refereing this method as dosomething(this); is this correct.
    – Suresh
    Apr 20, 2015 at 16:17

1 Answer 1


I solved this. {!REQUIRESCRIPT("/resource/jqueryResources/jquery.js")} {!REQUIRESCRIPT("/resource/jqueryResources/jquery-ui.js")}



jQuery('a').mousedown(function(event) {

if(event.which == 1){ window.open("URL","ITQ Email List",height="800", width="600"); } if(event.which == 3){ window.open("URL", target="_blank"); } })


  • Suri.. can you also post the code you have written to create the link? Apr 20, 2015 at 19:34
  • @Rajeev Shekhar . the code i have written is in the question and after the suggestion given by theGreatDanton, I wrote the code in answer.
    – Suresh
    Apr 21, 2015 at 13:03

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .