0

I am trying to separate my highslide popup from the onclick handler for my wordpress page due to limitations in my blog editor in including javascript with images.

I have found if I include a hs.expand in an onclick handler for any image on the page it works, but if there is not at least one the image is rendered in the top corner without the popup overlay.

This is my calling code

<a class="highslide" title="View 'View from Karasawa Hut' on Flickr.com" href="http://www.flickr.com/photos/colinc/6092830822"  > 

<img  style="float: left;" 
onclick="return show_my_pic(this,'http://farm7.staticflickr.com/6208/6092830822_1fd2545d5b.jpg','View from Karasawa Hut')" 
id="img1" alt="View from Karasawa Hut" src="http://farm7.staticflickr.com/6208/6092830822_1fd2545d5b.jpg" 
width="500" height="333" border="0" />
</a>

and this is the display function

<script>
function show_my_pic (thePic,theSrc,theTitle) {
  return hs.expand(thePic, {src : theSrc} );
}
</script>

If I include another link such as

<a  title="View 'View from Karasawa Hut' on Flickr.com" 
href="http://farm7.staticflickr.com/6208/6092830822_1fd2545d5b.jpg" 
onclick="return hs.expand(this)">

test

</a>

on the page somewhere the first link works, if I don't it doesn't.

The really strange part, if I delete the onclick handler in second link then the first one stops working.

From stepping through through the highslide javascript the Init does seem to be firing and the coordinates are being created it just doesn't render properly. I've spent many hours on this without success and would love some ideas?

Colin

4

1 に答える 1

0

Highslider では、ページが最初に読み込まれている必要があります。また、完全にロードされた画像要素を渡す必要があります

function init(){
    var img = document.getElementById('img1');
    show_my_pic(img, 'http://farm7.staticflickr.com/6208/6092830822_1fd2545d5b.jpg','View from Karasawa Hut');
}

...

<body onload="init()">
于 2013-12-01T10:42:31.043 に答える