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:<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!
誰かがあなたを助けてくれることを期待してイントロを削除しました。それが私たちがここにいることなので、あなたの質問を見ているのですから、あなたは良い人です。ようこそstackoverflowへ! :D –
changeDivs(p)のどこでどのくらい正確にpを取得していますか? – kjy112
これは私がchangeDivs関数を呼び出す方法です: –