You are here: Re: [PHP] possible jscript/php/frames question!! « PHP « IT news, forums, messages
Re: [PHP] possible jscript/php/frames question!!

Posted by Tom Rogers on 06/18/05 07:50

Hi,

Saturday, June 18, 2005, 8:47:58 AM, you wrote:
b> hi...

b> i've got a problem where i'm trying to play with imagemaps. i created a test
b> image map, but when i select inside the image map, i 'see' the "?x,y" from
b> the imagemap, appended to the url in the browser address bar... i get
b> http://foo.com?3,5 etc...

b> is there a way to prevent this from occuring??

b> i'd like to be able to select the imagemap, get the coordinate, and not have
b> the x,y mouse coordinate show up in the address bar...

b> i thought i could use an onClick, and go to a javascript function, but i
b> couldn't figure out how to get the mouse coordinates within the jscript
b> function.

b> if i slammed all this inside a frame, would that prevent the url-"x,y"
b> information from being displayed??

b> my sample code is below...

b> thanks

b> -bruce
b> bedouglas@earthlink.net


b> ----------------------------------------------------------------------------
b> ---
b> [root@lserver4 site]# cat map.php
b> <?
b> /*
b> test for image maps...
b> */
?>>
b> <?
b> $_self = $_SERVER['PHP_SELF'];
?>>

b> <html>
b> <body>
b> <script language="javascript" type="text/javascript">
b> <!--

b> function foo1(q)
b> {
b> // str = window.location.search
b> // document.write("fff "+q+"<br>");
b> // location.href="map.php";
b> // return true;
b> }
b> function foo(e)
b> {
b> //q = q+1;
b> mX = event.clientX;
b> mY = event.clientY;
b> // str = window.location.search
b> document.write("fff "+mX+" y= "+mY+"<br>");
b> location.href="map.php";
b> return true;
b> }
// -->>
b> </script>

b> <!--
b> <center><a href="<?=$_self;?>"><img
-->>

b> <center>
b> <!--
b> <a href="<?=$_self;?>" onclick ="alert(self.location.search); return false">
-->>
b> <a href="ff.php" onclick="">
b> <img src="imagemap.gif" ISMAP></a></center>
b> <p>
b> <script language="javascript" type="text/javascript">
b> <!--

b> str = location.search
b> if(str)
b> {
b> document.write("fff "+str+"<br>");
b> //location.href="map.php";
b> }

// -->>
b> </script>


b> </body>
b> </html>

A PHP solution to your problem is to save the x y co-ordinates in a
session and do a refresh, then get the values fom session.

Do something like

<?php
session_start();
if(isset($_SESSION['x']) && isset($_SESSION['y'])){
//do your thing here
unset($_SESSION['x'];
unset($_SESSION['y'];
}else{
//get x and y from request variables here
if($x && $y){
$_SESSION['x'] = $x;
$_SESSION['y'] = $y;
header('location: '.$_SERVER['PHP_SELF']);
exit;
}else{
//show start page
}
}
--
regards,
Tom

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация