Javascript 单击按钮但不';不要打开窗口或链接电子

Javascript 单击按钮但不';不要打开窗口或链接电子,javascript,html,electron,Javascript,Html,Electron,我在写一个程序来监控蒸汽市场的价格,我在electron中构建一个用户界面,问题是当我点击一个按钮时,它没有注册 我试过将它记录到控制台,或者发送到新窗口,或者打开一个链接,但都不起作用。我也厌倦了使用.on('click') index.js: const{BrowserWindow}=require('electron')。远程 const path=require('路径') 常量{shell}=require('electron') const launchbtn=document.ge

我在写一个程序来监控蒸汽市场的价格,我在electron中构建一个用户界面,问题是当我点击一个按钮时,它没有注册

我试过将它记录到控制台,或者发送到新窗口,或者打开一个链接,但都不起作用。我也厌倦了使用.on('click')

index.js:
const{BrowserWindow}=require('electron')。远程
const path=require('路径')
常量{shell}=require('electron')
const launchbtn=document.getElementById('launch')
launchbtn.addEventListener('单击',(事件)=>{
const modalPath=path.join('file://','u dirname','launch.html')
let win=新浏览器窗口({宽度:400,高度:320})
//shell.openExternal('http://electron.atom.io)试过了,但没用
win.on('close',()=>{win=null})
win.loadURL(modalPath)
win.show()

})
使用php和表单来实现这一点。表单应该具有php文件的操作,在php文件中,如果他单击了提交,您可以进行查询,然后创建标题位置:索引……等等。如果您需要,我可以向您发送代码。


    <!DOCTYPE html>
    <html>
      <head>
        <meta charset="UTF-8">
        <title>Hello World!</title>
        <link rel="stylesheet" href="../assets/css/main.css">
      </head>
      <body>
        
        <div class="row">
          <div id="price-container">
            <p class="subtext">test</p>
            <h1 id="About">test</h1>
          </div>
          <div id="goal-container">
            <p><span id="targetPrice">test</span></p>
          </div>
          <div id="right-container">
<form name="form-name" action="launch.php">
            <input type="submit" name="submit" value="Button Name">
</form>
          </div>
        </div>

        <script src="index.js"></script>
      </body>
    </html>

你好,世界!

测试

测试 试验


您可以通过Javascript轻松打开一个新窗口。下面可以看到代码。您只需快速查询即可

<button class="btn btn-success" onclick="location.href='http://google.com';"> Google</button>
Google

if(isset($_POST['Submit1']){header(“Location:”);}我从未使用过php,因此我不知道从何处开始该按钮工作,但它会打开php文件的内容并显示出来,而不是打开所需的窗口,这可能是因为您无法在计算机上调试php文件。您可以在Web空间中插入该按钮,但它已经工作了。我建议您使用该主机,因为您已经安装了hoster:我强烈认为使用PHP来实现这一点是没有必要的。afaik op只是想打开一个新窗口。我将用angular重写这个程序,看看这是否有助于我回复你,如果它不起作用,我会等待。angular不起作用,所以我现在要试试你的method,它工作了,但是我如何让它在一个新窗口中打开,并从src打开一个新窗口,比如launch.htmlIt,当你喜欢我的评论时会很好;)我帮不了你。