<html>
<head>
<script>
function replacesrc() {
var array= new Array();
array[1,2,3,4]=document.getElementById("From").value.split(" ");
document.getElementById("map").src="https://maps.google.com/maps?f=d&source=s_d&saddr="+array[1]+"+"+array[2]+"+"+array[3]+",+North+Augusta,+SC&daddr=Hilton+Head+Island,+SC&geocode=FYn4_wEd4BQd-ym_ve9aOTP4iDGvGGPbsAEwOw%3BFfyU6wEdINAv-ymtGdOO3Hn8iDE9KKLreqblLA&aq=1&oq=hi&sll=33.623768,-80.925293&sspn=5.551464,10.129395&hl=en&mra=ls&ie=UTF8&t=m&ll=32.88718,-81.37587&spn=1.3416,1.24656&output=embed"
document.getElementById("test").value=array[1,2,3,4];
}
</script>
</head>
<body>
<iframe id="map" width="425" height="350" frameborder="0" scrolling="no" marginheight="0" marginwidth="0" src="https://maps.google.com/maps?f=d&source=s_d&saddr=2000+Knobcone+Ave,+North+Augusta,+SC&daddr=Hilton+Head+Island,+SC&geocode=FYn4_wEd4BQd-ym_ve9aOTP4iDGvGGPbsAEwOw%3BFfyU6wEdINAv-ymtGdOO3Hn8iDE9KKLreqblLA&aq=1&oq=hi&sll=33.623768,-80.925293&sspn=5.551464,10.129395&hl=en&mra=ls&ie=UTF8&t=m&ll=32.88718,-81.37587&spn=1.3416,1.24656&output=embed"></iframe>
<br />From: <input id="From" type="text" /> <button onClick="replacesrc()">Directions</button><input id="test" type="text" value="test" />
<br /><small><a href="https://maps.google.com/maps?f=d&source=embed&saddr=2000+Knobcone+Ave,+North+Augusta,+SC&daddr=Hilton+Head+Island,+SC&geocode=FYn4_wEd4BQd-ym_ve9aOTP4iDGvGGPbsAEwOw%3BFfyU6wEdINAv-ymtGdOO3Hn8iDE9KKLreqblLA&aq=1&oq=hi&sll=33.623768,-80.925293&sspn=5.551464,10.129395&hl=en&mra=ls&ie=UTF8&t=m&ll=32.88718,-81.37587&spn=1.3416,1.24656" style="color:#0000FF;text-align:left">View Larger Map</a></small>
</body>
</html>
那是我的代码。它一直以未定义的方式传递它。有人可以帮我吗?我尝试了不同的方法来解决这个问题。但我还是不行。从我的观点来看,我做对了,因为我放了一个测试函数来查看它正在发送什么,我得到了同样的东西,但是当它把它放在 src 中时,它把它设置为未定义。