Electronã®webviewè¦ç´ ã§ã¯allowpopupså±æ§ãã¤ãã¦ã¯ãããªã
Electronã使ã£ã¦ãã©ã¦ã¶ã®ãããªã¢ããªã±ã¼ã·ã§ã³ãä½ãå ´åã«ã¯ webviewã¿ã°ã使ç¨ããããä¾ãã°ãã¢ããªã±ã¼ã·ã§ã³å ã«example.jpã®ãµã¤ãã表示ããã«ã¯ä»¥ä¸ã®ããã«HTMLã«è¨è¿°ããã
<webview src="http://example.jp/"></webview>
ããã§ãwebviewã¿ã°ã«allowpopupså±æ§ãä»ä¸ããã¨ãexample.jpãµã¤ãå ã®ã³ã¼ãããwindow.opençã使ã£ã¦æ°ãã«ã¦ã£ã³ãã¦ãéããã¨ãã§ããããã«ãªãããã®ã¨ããexample.jpã«æªæããã以ä¸ã®ãããªã³ã¼ããå«ã¾ãã¦ããã¨ããã
if( typeof require === "undefined" ) window.open( 'http://example.jp/', '', 'nodeIntegration=1'); else require( "child_process").exec("calc.exe",function(){});
requireãæªå®ç¾©ã®å ´åã«ã¯èªèº«ã®ãµã¤ããwindow.openã使ã£ã¦éããªããã¦ãããããã®ã¨ãã«'nodeIntegration=1'ãä¸ãã¦ãããããã«ãããæ°ãã«çæãããwindowã§ã¯nodeã®æ©è½ããªãã¡requireãprocessãªã©ãå©ç¨å¯è½ã«ãªããã³ã¼ãã®else以éã¯éããªããããwindowå
ã§åä½ããrequireãå©ç¨å¯è½ã«ãªã£ã¦ããã®ã§ãããã§ã¯é»åãèµ·åãã¦ããã
ãã®ããã«ãwebviewã¿ã°ã«allowpopupså±æ§ãä»ä¸ããã¦ããå ´åãwebviewå
ã«è¡¨ç¤ºããã¦ãããµã¤ãããã¯ã©ã¤ã¢ã³ãPCä¸ã§ä»»æã³ã¼ãã®å®è¡ãå¯è½ã«ãªãå¯è½æ§ãããã
ããã§æ³¨æãã¹ãã¯ãallowpopupså±æ§ã¯ããã¾ã§ãæ°ãã«ãããã¢ããã¦ã£ã³ãã¦ãéããã¨ã許å¯ãã¦ããã ãã§ãããéãããã¦ã£ã³ãã¦ãnodeæ©è½ãå©ç¨å¯è½ãã©ãããå¶å¾¡ãã¦ããã®ã§ã¯ãªãã¨ãããã¨ã§ãããç¾ç¶ã®nodeã§ã¯ãæ°ãã«ã¦ã£ã³ãã¦ãéãéã«nodeæ©è½ããªã³ã«ãã¦éããã¨ãã§ããããallowpopupsãä»ä¸ããªããã¨ã«ãã£ã¦æ°ãã«ã¦ã£ã³ãã¦ã®çæãç¦æ¢ãã¦ãããã¨ããã¾ãã¾nodeæ©è½ä»ãã§ã³ã¼ãå®è¡ãããã®ãç¦æ¢ãã¦ããã®ã«éããªãã¨ããç¹ã«çæãã¦ããå¿ è¦ãããã
ã¾ã¨ããwebviewã¿ã°ã«allowpopupså±æ§ãã¤ãã¦ãªã¢ã¼ããµã¤ãã表示ãã¦ããå ´åããªã¢ã¼ããµã¤ãããä»»æã³ã¼ãã®å®è¡ãå¯è½ã«ãªãã