javascriptjquerypopupwindowpopup-blocker

Javascript opening a link


I am trying to open a link in a new tab/window when a user presses a key.

Here is the function I made for opening a link, it gets called when the user presses the "X" key.

function open_link() {
    window.open($("#active").attr("link"), '_blank');
}

My page consists of a bunch of divs looking like this, and the user sets the active one by navigating up/down with the keys j/k. All this works, but the problem is that there is a popup blocked warning when the "X" key is pressed to open the link.

<div class="read entry" id="active" entryNumber="0" entryId="733" link="http://www.reddit.com/r/buildapc/comments/1aux43/build_help_ordering_soon_final_review/">

Solution

  • I don't think you can disable popup blocker from javascript. If you could, then popup blockers would be quite useless. Have you considered using modal divs instead? E.g. modal dialog from jQueryUI.