如何将 javascript 实现到 html 页面
How to implement javascript into an html page
我想将此脚本实现到 html 页面中:
function rcirc(x, y, m, b) {
let m2 = -1 / m;
let b2 = y - (m * x);
let y2 = (b2 - b) / (m - m2);
let x2 = (y2 - b) / m;
return [x2, y2];
}
var x = window.prompt("enter the x value: ");
var y = window.prompt("enter the y value: ");
var m = window.prompt("enter the m value: ");
var b = window.prompt("enter the b value: ");
let point = rcirc(x, y, m, b);
alert(point);
我尝试在代码周围添加 <script></script>
但它不起作用。
您好 Hoadi,这里是您的代码在 html“网站”中实现的一个工作示例。
html 在您单击最终警报后呈现。
<hml>
<body>
<h1>some stuff...</h1>
</body>
<script>
function rcirc(x, y, m, b) {
let m2 = -1/m;
let b2 = y - (m * x);
let y2 = (b2 - b) / (m - m2);
let x2 = (y2 - b) / m;
return [x2, y2];
}
var x = window.prompt("enter the x value: ");
var y = window.prompt("enter the y value: ");
var m = window.prompt("enter the m value: ");
var b = window.prompt("enter the b value: ");
let point = rcirc(x, y, m, b);
alert(point);
</script>
</hml>
希望对您有所帮助。
我想将此脚本实现到 html 页面中:
function rcirc(x, y, m, b) {
let m2 = -1 / m;
let b2 = y - (m * x);
let y2 = (b2 - b) / (m - m2);
let x2 = (y2 - b) / m;
return [x2, y2];
}
var x = window.prompt("enter the x value: ");
var y = window.prompt("enter the y value: ");
var m = window.prompt("enter the m value: ");
var b = window.prompt("enter the b value: ");
let point = rcirc(x, y, m, b);
alert(point);
我尝试在代码周围添加 <script></script>
但它不起作用。
您好 Hoadi,这里是您的代码在 html“网站”中实现的一个工作示例。 html 在您单击最终警报后呈现。
<hml>
<body>
<h1>some stuff...</h1>
</body>
<script>
function rcirc(x, y, m, b) {
let m2 = -1/m;
let b2 = y - (m * x);
let y2 = (b2 - b) / (m - m2);
let x2 = (y2 - b) / m;
return [x2, y2];
}
var x = window.prompt("enter the x value: ");
var y = window.prompt("enter the y value: ");
var m = window.prompt("enter the m value: ");
var b = window.prompt("enter the b value: ");
let point = rcirc(x, y, m, b);
alert(point);
</script>
</hml>