CodyKochmann
8/17/2016 - 8:42 PM

open links with javascript with these easy to use functions

open links with javascript with these easy to use functions

(function() {
  window.open_link = function(url) {
    window.location = url;
  };

  window.open_in_new_tab = function(url) {
    return window.open(url, '_blank');
  };

  window.open_link_in_new_tab_and_focus = function(url) {
    var win;
    win = open_in_new_tab(url);
    win.focus();
  };

  window.open_link_in_new_window = function(url) {
    return window.open();
  };

  window.open_multiple_new_windows = function(url_list) {
    var i, j, len, results;
    results = [];
    for (j = 0, len = url_list.length; j < len; j++) {
      i = url_list[j];
      results.push(window.open(i));
    }
    return results;
  };

  window.open_link_in_stylized_window = function(url, style) {
    if (style == null) {
      style = "toolbar=yes,scrollbars=yes,resizable=yes,top=500,left=500,width=400,height=400";
    }
    return window.open(url, "_blank", style);
  };

}).call(this);
window.open_link=(url)->
    window.location=url
    return

window.open_in_new_tab=(url)->
    window.open(url,'_blank')

window.open_link_in_new_tab_and_focus=(url)->
    win=open_in_new_tab(url)
    win.focus()
    return

window.open_link_in_new_window=(url)->
    # open link
    window.open()

window.open_multiple_new_windows=(url_list)->
    for i in url_list
        window.open(i)

window.open_link_in_stylized_window=(url, style="toolbar=yes,scrollbars=yes,resizable=yes,top=500,left=500,width=400,height=400")->
    window.open(url, "_blank", style)