Window.openをカプセル化して、より便利で互換性のあるものにします。多くの人がwindow.openは互換性がないと言いますが、直接実行できず、ユーザーが手動でトリガーする必要があるためではありません。コードを参照してください:
コードは次のとおりです
var openwindow = function(url、options){var str = ""; if(options){options.height = options.height || 420; options.width = options.width || 550; options.left = options.left || ((screen.width -options.width) / 2); //デフォルトは中央options.top = options.top ||です((screen.height -options.height) / 2); //デフォルトは(オプションのvar i){str + = '、' + i + '=' + options [i];} str.substr(1);}; window.open(url、 'connect_window _' +( + new date)、str) Webサイトdocument.onclick = function(){openWindow( "http://www.daermay.com/?rel = xuexb");} // demo 2:fixed width and centered document.body.onclick = function(){openwindow( "// www.vevb.com/?