I developed a html page with a bit of javascript. I have several tags and after clicking a link one of them is dynamically assigned a background image. This url is stored in a global variable. So far so good.html/javascript: en utilisant une variable comme URL pour <a href>
var picture,thumb
function changeDivs(p)
{
if (p!='') {
picture = './images/p'+p+'.jpg'; // global url variable
thumb = './thumbs/p'+p+'.jpg'; // global url variable
var pic = "url("+thumb+")";
document.getElementById("poster").style.backgroundImage = pic;
}
}
I call the function like this:
<a href="javascript:changeDivs('2')">Link</a>
Now I want to make use of a thumbnailviewer script which needs to be accessed like this:
<a href="javascript: global variable" rel="thumbnail"> <!-- Of course this "javascript: global variable" should be a valid url: the stored 'picture' variable -->
<div id="poster">
</div>
</a>
So I have stored the url in variable: picture
How can I access the thumbnailviewer script through <a href>
AND use the variable. I don't know if the thumbnail script can be called through a function or how.
Thanks a lot!
J'ai supprimé votre intro en espérant que quelqu'un puisse vous aider. C'est pour cela que nous sommes tous ici et c'est pourquoi nous examinons votre question, donc vous êtes entre de bonnes mains. Bienvenue sur stackoverflow! : D –
où et comment exactement obtenez-vous le p dans changeDivs (p)? – kjy112
Voici comment j'appelle la fonction changeDivs: –