前几天我刚开始学习 JS,我(当然)遇到了一些困难。我通常会很快掌握事情,但我无法终生找到解决方案。我想了解为什么会这样。
我的目标是使用3个提示框,依次出现,打印出一段html代码,这将是一个简单的URL。我会添加更多内容,但我想先解决这个问题。
目前,我收到了提示,但是在我将数据输入第三个框并提交后,什么也没有发生。
我在这里做错了什么?如果我的 document.write 代码有错误,我应该注意哪些事项?
谢谢!..
function show_prompt()
{
var site_type = prompt("What kind of link is this?");
var site_url = prompt("What is the URL?");
var site_title = prompt("Give the link a title");
if (site_type = website) {
document.write("<a style=\"color: #777777\" href=\"http:\/\/site_url\" title=\"site_title\">site_title<\/a>");
}
else
if (site_type = video) {
document.write("<a style=\"color:#98B2C3\" href=\"http:\/\/site_url\" title=\"site_title\">site_title<\/a>");
}
else
if (site_type = image) {
document.write("<a style=\"color:#8D5359\" href=\"http:\/\/site_url\" title=\"site_title\">site_title<\/a>");
}
else
(site_type = article); {
document.write("<a style=\"color:#768D53\" href=\"http:\/\/site_url\" title=\"site_title\">site_title<\/a>");
}
}