Forum Moderators: open
I have a script that enables a pawn to walk on a specific road and you can walk the pawn with WASD keys.
This works well only I have a small problem.
Everytime I press one of the keys to move the pawn, the whole screen reloads.
The base walking map is made out of 9 iframes, that loads a small part of the map, whenever you walk the map will move with you.
Anyway, here is a small part of the walking code.
?> <SCRIPT LANGUAGE="JavaScript"> var key = new Array(); key['w'] = "mapping2.php?pos=<?=$posw?>"; function getKey(keyStroke) { isNetscape=(document.layers); eventChooser = (isNetscape)? keyStroke.which : event.keyCode; which = String.fromCharCode(eventChooser).toLowerCase(); for (var i in key) if (which == i) window.location = key[i]; } document.onkeypress = getKey; </script> <?php Whenever I press 'w' my char will walk one roadpoint up.
This works fine.
Here are the Iframes.
echo "<iframe frameborder=\"0\" allowTransparency=\"true\" height=\"40\" width=\"40\" name=\"frame1\" scrolling=\"no\" src=\"http://###/mainmap2.php?pos=$pos#x$iframe1\"></iframe>"; echo "<td><iframe frameborder=\"0\" allowTransparency=\"true\" height=\"40\" width=\"40\" name=\"frame1\" scrolling=\"no\" src=\"http://###/mainmap2.php?pos=$pos#x$iframe2\"></iframe>"; echo "<td><iframe frameborder=\"0\" allowTransparency=\"true\" height=\"40\" width=\"40\" name=\"frame1\" scrolling=\"no\" src=\"http://###/mainmap2.php?pos=$pos#x$iframe3\"></iframe><br>"; echo "<tr><td><iframe frameborder=\"0\" allowTransparency=\"true\" height=\"40\" width=\"40\" name=\"frame1\" scrolling=\"no\" src=\"http://###/mainmap2.php?pos=$pos#x$iframe4\"></iframe>"; //Middle IFRAME! echo "<td><iframe frameborder=\"0\" allowTransparency=\"true\" height=\"40\" width=\"40\" name=\"frame1\" scrolling=\"no\" src=\"http://###/mainmap2.php?pos=$pos#x$pos\"></iframe>"; echo "<td><iframe frameborder=\"0\" allowTransparency=\"true\" height=\"40\" width=\"40\" name=\"frame1\" scrolling=\"no\" src=\"http://###/mainmap2.php?pos=$pos#x$iframe6\"></iframe><br>"; echo "<tr><td><iframe frameborder=\"0\" allowTransparency=\"true\" height=\"40\" width=\"40\" name=\"frame1\" scrolling=\"no\" src=\"http://###/mainmap2.php?pos=$pos#x$iframe7\"></iframe>"; echo "<td><iframe frameborder=\"0\" allowTransparency=\"true\" height=\"40\" width=\"40\" name=\"frame1\" scrolling=\"no\" src=\"http://###/mainmap2.php?pos=$pos#x$iframe8\"></iframe>"; echo "<td><iframe frameborder=\"0\" allowTransparency=\"true\" height=\"40\" width=\"40\" name=\"frame1\" scrolling=\"no\" src=\"http://###/mainmap2.php?pos=$pos#x$iframe9\"></iframe>"; The middle Iframe always shows the current position of the pawn.
The iframes mirror to the page with the graphics, and the graphics are all mapped into #locations.
You can use guest login to check it out, mail me if you think you can help me out, and I give you weblink if you can help me, so you can see it working.
The whole point:
I want only the IFRAMES to refresh, or at least the middle Iframe, the rest will tag along anywayz :).
Can someone help me out? mail me on <snip> if you need more code. (I cant give more in public, lost one script before on some wannabee programmers).
I tried stuff, but I cant get it to work like adding
function refreshiframe() { parent.iframeid.location.href="thepage.com" Thanks in advance!
[edited by: Deputy at 8:27 pm (utc) on Nov. 19, 2008]
[edited by: eelixduppy at 11:54 pm (utc) on Nov. 19, 2008]
[edit reason] removed email [/edit]
if ($pos == '331')
{
?> <SCRIPT LANGUAGE="JavaScript">
var key = new Array();
key['w'] = "mainmap2.php?pos=<?=$posw?>#x<?=$posw?>";
function getKey(keyStroke) {
isNetscape=(document.layers);
eventChooser = (isNetscape)? keyStroke.which : event.keyCode;
which = String.fromCharCode(eventChooser).toLowerCase();
for (var i in key) if (which == i) self.frames['frame5'].location = key[i];
}
document.onkeypress = getKey;
</script>
<?php
}
else
{
echo "";
}