我刚刚开始学习JS,并且当然有一些困难。我通常很快把握事情,但我不能为我的生活找到解决办法。我想了解为什么会发生这种情况。JS:通过document.write显示HTML w /变量
我的目标是使用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>");
}
}
感谢Steerpike(和安德烈斯) 确定。我现在已经完成了这个工作,不过,在提交第三个提示后,我仍然遇到同样的最终结果。 – 2009-09-01 19:26:26
真棒,它完美的作品..谢谢你Steerpike ..伤心地在这一整天。现在我终于可以放下头来休息了。 非常感谢! (并感谢你们其他人为了鸣叫) – 2009-09-01 19:55:40