HTML按钮不重定向到Java邮件正文中的给定链接

问题描述 投票:0回答:2

我想为我正在创建的HTML电子邮件模板添加一个按钮。我已经创建了一个按钮但是当我点击它时,链接不会出现。任何人都可以帮我解决我的问题吗?

这是我的代码:

messageBodyPart.setContent("<h1>You Have a Promotion</h1> <h3>Your First Name :</h3>" + FirstNm + 
                      "<h3>Your Last Name :</h3>" + LastNm + "<h3>Your Employee ID :</h3>" + Employeeid + 
                      " <br/> <form>\r\n" + 
                            "<input class=\"MyButton\" onclick =\"http://localhost:8080/update/status/password/ACCEPT\" type = \"button\" value =\"Accept Your Promotion\" />\r\n" + 
                      "</form>","text/html");
java html button onclick
2个回答
1
投票

尝试在href元素上添加锚标记并使用onclick属性而不是input事件。

messageBodyPart.setContent("<h1>You Have a Promotion</h1> <h3>Your First Name :</h3>" + FirstNm + 
                      "<h3>Your Last Name :</h3>" + LastNm + "<h3>Your Employee ID :</h3>" + Employeeid + 
                      " <br/> <form>\r\n" + 
                            "<a href=\"http://localhost:8080/update/status/password/ACCEPT\"><input class=\"MyButton\"  type = \"button\" value =\"Accept Your Promotion\" /></a>\r\n" + 
                      "</form>","text/html");

0
投票

你可以使用这样的输入:<input type="button" onclick="window.location='https://www.yourdomain.com/'" value='Go'>

<html>
	<head></head>
	
	<body>
	
		<input type="button" onclick="window.location='https://www.yourdomain.com/'" value='Go'>
	</body>
</html>
© www.soinside.com 2019 - 2024. All rights reserved.