0
我需要將函數從下面的html文檔中拉出來,創建一個單獨的js文檔,它將包含函數並修改我現有的代碼,以便它包含我的js文件。然後,我必須在我的html文件中創建一個名爲「DoTheLink」的新功能。我將從我的js文件中的函數調用該函數。 「DoTheLink」將通過網站變量並設置按鈕的onclick屬性。將函數移動到java腳本
這是我有工作:
<!DOCTYPE html>
<html>
<head>
<title>funky jumper </title>
</head>
<body>
<script>
var surfCaption="You\'ve selected: Bird Rock Surf Cam";
var surfButton="Bird Rock Surf Cam";
var surfWeb="http://www.surfline.com/surf-report/birdrock-7-california_4249";
var grandmaCaption="You\'ve selected: Grandma\'s Weather";
var grandmaButton="Grandma\'s Weather";
var grandmaWeb="http://www.weather.com/weather/today/Bronx+NY+10463:4:US";
var dollCaption="You\'ve selected: Noodle-head sewing";
var dollButton="Noodle-head sewing";
var dollWeb="http://www.noodle-head.com/2010/01/another-round-of-black-apple-dolls.html";
</script>
<div style="text-align: center">
<table align="center">
<td> <img src="http://nees.oregonstate.edu/killer_wave/wave.jpg" alt="Surf" border="3" height="280" width="172" onclick="uno(surfCaption, surfButton, surfWeb);">
</td>
<td> <img src="http://wirednewyork.com/images/city-guide/liberty/liberty.jpg" alt="Grandma's Weather" border="3" height=280 width=200
onclick="uno(grandmaCaption, grandmaButton, grandmaWeb);">
</td>
<td> <img src="http://4.bp.blogspot.com/__A1V8kztPXs/S1XYcpBScbI/AAAAAAAAA00/S_nd0bNtUR8/s640/helpfulhannahpresent3.jpg" alt="Noodle-head" border="3" height=280 width=180
onclick="uno(dollCaption, dollButton, dollWeb);">
</td>
</table>
<p id="captionUnderTable" >Nothing Selected</p>
<br>
<button id="NewButton" >Click on a picture, then click me to go!</button>
</div>
<script>
function uno(Caption, Button, Web)
{
document.getElementById("captionUnderTable").innerHTML=Caption;
document.getElementById("NewButton").innerHTML=Button;
document.getElementById("NewButton").setAttribute('onclick','window.location.href="'+Web+'";')
<!--When the picture is clicked, go get the variable associated with that picture-->
}
</script>
</body>
</html>
,什麼是問題嗎? – Misters