【发布时间】:2022-07-06 00:32:03
【问题描述】:
我有以下 html 代码。
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<script>
function myTermsandConditions(){
var myWindow = window.open("","MsgWindow","width=200,height=200");
myWindow.document.write("<p>This is Terms and Conditions Window. Please go through all the Terms and Conditions for your references.</p>")
}
</script>
</head>
<body>
<label class="sign_agree">
<span id="signup-termservice" class="unchecked">
</span>I agree to the
<a href="" >Terms and Conditions</a>
.
</label>
<button onclick="myTermsandConditions()">T&C</button>
</body>
</html>
这里有一个 T&C 按钮,当我单击该按钮时,将打开一个窗口并显示使用函数 myTermsandConditions() 给出的自定义消息。 但我正在尝试对条款和条件链接实施相同的操作。根据我的要求,我不应该使用该按钮,但是当单击下面给出的条款和条件链接时,应使用 myTermsandConditions() 函数打开窗口或弹出窗口。
<a href="" >Terms and Conditions</a>
我正在努力寻找解决方案并在此过程中学习。
【问题讨论】:
-
我认为你可以在 href 元素中添加 onclick 功能
标签: javascript