简体   繁体   English

试图获取一个按钮作为提交按钮

[英]Trying to get a button to work as a submit button

I am trying to figure out how to make this HTML submit button work correctly. 我试图弄清楚如何使此HTML提交按钮正常工作。 Below is the code for the submit button: 以下是提交按钮的代码:

<form action ="itms-services://?action=download-manifest&url=https://icustomer.apsresource.com/ipad_apps/survey/user/APSSurvey.plist">
    <button type="submit" name="Download" value="download" onclick="JavaScript:alert('You will be downloading the APS Resource iPAD PRODUCT SURVEY.')" style="width:255px; height:310px; -webkit-appearance: none; -webkit-border-radius:0px;">
        <img src="apple.png"  />
    </button>
</form>

When the button is clicked, it is supposed to open up the URL in the "action" part in the form tag. 单击该按钮时,应该在表单标签的“操作”部分中打开URL。 However, all I get is the JS pop-up, but no URL is opened (looking at the console, a GET function is triggered, then instantly canceled). 但是,我得到的只是JS弹出窗口,但是没有打开URL(在控制台上,触发了GET函数,然后立即将其取消了)。 IS there something I need to add/remove in order for this to work? 是否需要添加/删除某些内容才能使其正常工作?

Submit the form with the onclick event 提交带有onclick事件的表单

onclick="alert('You will be downloading the APS Resource iPAD PRODUCT SURVEY.');this.form.submit();"

You don't need to put the work JavaScript in your event either. 您也不需要在事件中放入工作JavaScript。

BTW, you don't really need to have this.form.submit() at all. 顺便说一句,您实际上根本不需要this.form.submit()。 I took your original and removed JavaScript from the onlick and changed the action and your code works fine. 我拿走了您原来的JavaScript,并从onlick中删除了JavaScript,并更改了操作,您的代码运行正常。 I'm not sure what itms-services:// is but it's not a valid HTTP protocol like http:// or https://. 我不确定itms-services://是什么,但是它不是有效的HTTP协议,例如http://或https://。

Here's a jsfiddle illustrating this. 这是一个说明这一点的jsfiddle

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM