我是新編碼php和javascript。將這個changeContent函數放入我的代碼後,它沒有找到它。顯示參考錯誤,我認爲它與鏈接中的「//」有關。我將如何去修復它?ReferenceError:函數未定義
<?php
$one = "<iframe src='http://www.google.com' width='100%' height='84%' frameborder='0'></iframe>";
$two = "<iframe src='http://www.facebook.com' width='100%' height='84%' frameborder='0'></iframe>";
$three = "<iframe src='http://www.youtube.com' width='100%' height='84%' frameborder='0'></iframe>";
echo "
<html xmlns='http://www.w3.org/1999/xhtml' xmlns:fb='http://developers.facebook.com/schema/' version='XHTML+RDFa 1.0' xml:lang='en'
<head>
<link type='text/css' rel='stylesheet' href='style.css'/>
<script type='text/javascript'>
function changeContent() {
document.getElementById('content').innerHTML='<?=$one?>';
}
</script>
<script type='text/javascript'>
function changeContent2() {
document.getElementById('content').innerHTML='<iframe src='<?=$two?>' width='100%' height='84%' frameborder='0'></iframe>';
}
</script>
<script type='text/javascript'>
function changeContent3() {
document.getElementById('content').innerHTML='<iframe src='<?$three?>' width='100%' height='84%' frameborder='0'></iframe></iframe>';
}
</script>
</head>
<body>
<div id='topplace'>
<ul>
<li><a href='#' class='classname' onClick=\"changeContent()\">google <small class='button'>Test</small></a></li>
<li> </li>
<li><a href='#' class='classname' onClick=\"changeContent2()\">facebook <small class='button'>Test</small></a></li>
<li> </li>
<li><a href='#' class='classname' onClick=\"changeContent3()\">youtube <small class='button'>test</small></a></li>
</ul>
</div>
</body>";
?>
你可能會得到一個很大的提示,如果你看看實際生成的HTML頁面(如在瀏覽器中使用View/Source)。 – jfriend00