Principle:
Operation Flow:
First click on the avatar image, pop up the selection window, select one of the window to launch avatar replacement.
Effect:
Main Page code:
<tr> <td> Avatar:</td> <td><input type="Hidden"Name=" Face"Value=""/> "./face/m01.gif"alt="Avatar" class=" Face"Id='faceimg'onclick="javascript:window.open (' face.php ', ' face ', ' Width=420,height=600,top=0,left=0,scrollbars=1 ');"/></td></tr>
Child page code (popup form page):
<div id="face"> foreachas $num) { "". $num."' alt= ' face /". $num."' title= '". $num."'/>' ; }? > </div>
Use the JS code:
Reference:
<!--Click Change Avatar --<script type="text/javascript" src= "./js/ Face.js"></script>
Code:
Window.onload =function () {//get the Avatar object in the face.php page varimg = document.getElementsByTagName ('img'); //to cycle for(i=0; i){ //trigger A Click event on the selected objectImg[i].onclick =function () {//Call the _opener () function_opener ( This. alt); }; }}//Show Avatar functionfunction _opener (src) {//Get parent page Avatar Object varFaceimg = Opener.document.getElementById ('faceimg'); //Change your avatar's imgFACEIMG.SRC =src; //Change the value of name in the register form in the parent page to SRC. Opener.document.register.face.value =src;}
PHP-click Change Avatar