是朋友剛好問我的
他希望能寫一個A網頁可以傳變數,然後B網頁去接收變數
變數名稱則為圖片的名稱
所以我就要幫忙他弄了,真是心酸
寫好後的成果如下
TestA.htm
<html>
<head>
<script type="text/javascript">
function getValue(gValue)
{
window.location.href = "testB.html?" + gValue + "&";
}
</script>
</head>
<body>
//要傳送的變數
<a href="javascript:getValue('aa')">img1</a>
<br>
<a href="javascript:getValue('bb')">img2</a>
</script>
</body>
</html>
TestB.htm
<html>
<head>
<script type="text/javascript">
function ShowImg()
{
var textget = window.location.search.substring (1);
var tmp_img = "<IMG SRC='" + textget.substring(0,textget.search ("&")) +".jpg'>";
return(tmp_img);
}
</script>
</head>
<body>
<br>
<script type="text/javascript">
document.write(ShowImg())
</script>
</body>
</html>
******************************************
是個簡單的例子
而且也沒有寫的很好
但可以應用在很多地方上
我個人覺得啦
哈哈