Skip to content

Instantly share code, notes, and snippets.

@laispace
Created July 28, 2015 08:45
Show Gist options
  • Save laispace/ae3c60783d342cfeaa16 to your computer and use it in GitHub Desktop.
Save laispace/ae3c60783d342cfeaa16 to your computer and use it in GitHub Desktop.

Revisions

  1. laispace created this gist Jul 28, 2015.
    12 changes: 12 additions & 0 deletions openWindowByUrl.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,12 @@
    /**
    * 打开一个新的页面
    * @param {String} url
    */
    openWindowByUrl: function(url) {
    var a = document.createElement('a');
    a.href = '';
    a.setAttribute("target", '_blank');
    var evt = document.createEvent("HTMLEvents");
    evt.initEvent("click");
    a.dispatchEvent(evt);
    },