我剛剛開始學習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