我正在尝试使用onclick元素更改javascript对象中包含的图像URL,以便可以将图像替换为不同的图像-这是一个全景图像,所以不幸的是,不是一个简单的图像更改!
目标代码为:
<div id="img-251" style="width:100%;max-width:800px;height:80vh;max-height:600px;"></div>
</div>
<script>
var viewer251 = new PhotoSphereViewer({
container: 'img-251',
touchmove_two_fingers: false,
time_anim: false,
anim_speed: '1rpm',
caption: 'Bedroom',
panorama: 'http://pallighting.com.au/wp-content/uploads/2020/07/website-360-test0000.jpg',
navbar: [
'autorotate',
'zoom',
'caption',
{title: 'Normal Size',className: 'sps-icon',content: '',onClick: function() {document.getElementById('spscontent-251').setAttribute("style","padding:10px");document.getElementById('img-251').setAttribute("style","width:100%;max-width:800px;height:80vh;max-height:600px;");viewer251.resize({width:100,height:80});}},
{title: 'Full Size',className: 'sps-icon',content: '',onClick: function() {document.getElementById('spscontent-251').setAttribute("style","position: fixed;top: 0;left: 0;right: 0;bottom: 0;background: rgba(0,0,0,.5);z-index: 700;");document.getElementById('img-251').setAttribute("style","width:100%;height:100%");document.getElementById('spscontent-251').setAttribute("style","max-width:100%;position: fixed;top: 0;left: 0;right: 0;bottom: 0;background: rgba(0,0,0,.5);z-index: 99999;margin: 0;width: 100%;");viewer251.resize({width:100,height:80});}}
],
lang: {
autorotate: 'Automatic rotation',
zoom: 'Zoom',
zoomOut: 'Zoom Out',
zoomIn: 'Zoom In',
two_fingers: ['Use two fingers to navigate']
}
});我正在尝试使用onclick图像来更改此代码中的图像。我尝试过不同的方式来写东西,例如,使用或不使用viewer251或PhotoSphereViewer变量名……
<img src="http://pallighting.com.au/wp-content/uploads/2020/06/logo.png" onClick="viewer251.PhotoSphereViewer.panorama: 'http://pallighting.com.au/wp-content/uploads/2020/07/website-360-test0001.jpg'">用这种方法不走运,任何帮助都将不胜感激!
发布于 2020-07-09 15:07:36
您可以使用setPanorama方法
<img src="http://pallighting.com.au/wp-content/uploads/2020/06/logo.png"
onClick="viewer.setPanorama('http://pallighting.com.au/wp-content/uploads/2020/07/website-360-test0001.jpg')">https://stackoverflow.com/questions/62808981
复制相似问题