Jump to content

Area Shape


jrv
 Share

Recommended Posts

boa tarde

eu tenho um mapa que é uma div e que esta dividido em varias area shape, e quero que apareça uma imagem noutra div quando passo com o rato numa área (este passo esta conseguido) e quero que apareça noutra div uma palavra também quando passo na área dentro do mapa.Alguém me consegue ajudar com alguma função? Obrigado

Link to comment
Share on other sites

A função que estou a utilizar para por a imagem é a seguinte:

function LoadGallery(image, UrlFrom){

if(typeof UrlFrom == "object" || UrlFrom == "[object]"){

document.getElementById(image).src = UrlFrom.src;

}

else{

document.getElementById(image).src = UrlFrom;

}

}

como é para duas divs diferentes não sei como adaptar isto...

Link to comment
Share on other sites

o texto que queres escrever está onde? não vem como parâmetro para esta função? tipo

function LoadGallery(image, UrlFrom, textoParam){
if(typeof UrlFrom == "object" || UrlFrom == "[object]"){
   document.getElementById(image).src = UrlFrom.src;
   document.getElementById(divTexto).innerHTML = textoParam;
   }
else{
   document.getElementById(image).src = UrlFrom;
   
   }
}

não tenho a certeza se é innerHTML mas não é por aí...

Link to comment
Share on other sites

o texto que quero que apareça vai depender da area que esta a ser selecionada no mapa, ou seja não entra como parametro, se calhar neste caso teria que ter outra funcao??!!!

pois, crias uma função para ir buscar o texto (tb pode ficar dentro desta)...

ideia: usar o atributo "alt" da imagem para guardar esse texto que queres apresentar, dependendo do cenário pode ser uma solução 😉

Link to comment
Share on other sites

ja tentei dessa forma,mas nao estou a conseguir chamar da mellhor forma...

onmouseover="LoadGallery('ola',teste.png',??????????);

var texto = getElementById(descricao).alt

function LoadGallery(image, UrlFrom, texto){

if(typeof UrlFrom == "object" || UrlFrom == "[object]"){

  document.getElementById(image).src = UrlFrom.src;

  document.getElementById(descricao).innerHTML = texto;

  }

else{

  document.getElementById(image).src = UrlFrom;

 

  }

}

Link to comment
Share on other sites

var texto = getElementById(descricao).alt [falta o document tipo document.getElement...]

este código está a funcionar no FF3,  IE8 e Opera

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Untitled Page</title>
<script type="text/javascript">
function LoadGallery()
{
var txt = document.getElementById("dass").alt;
document.getElementById("div2").innerHTML = txt;
}
</script>

</head>
<body>
<p id="aa" onmouseover="LoadGallery()">blaaaaa</p>
<br />
<br /> 
<img id="dass" name="dass" src="" alt="alt da imagem" />
<br />
<br /> 
<p id="div2" onmouseover="LoadGallery()"></p>
</body>
</html>
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...

Important Information

By using this site you accept our Terms of Use and Privacy Policy. We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.