我正在建立一个漫画标签的投资组合网站,并希望将商店整合到该网站中。该网站内置于Indexhibit,我一直在尝试几种选择。
目前,我只希望能够在每个产品的单独页面上都具有“立即购买”链接,并使其在锚点中打开或在商店页面向下滚动至该页面。商店页面是在iframe中在网站内打开的Tictail商店。
这是单个页面:http : //www.clubedoinferno.com/index.php/project/yonkoma-collection-vol1/
您可以看到链接代码为
<a href="http://www.clubedoinferno.com/index.php/store/">BUY NOW</span></a>
由于Tictail启用主题自定义,因此在商品的DIV名称中引入了该商品在商店的定位点:
<div id="fH9a">x</div>
使用诸如在我的链接中添加#fH9a之类的基本内容无效。请帮忙?
我认为您不使用脚本就无法做到这一点。
在iframe页面中添加以下内容
<script>
window.scrollTo(0,document.getElementById(parent.window.location.hash.substring(1)).offsetTop);
</script>
以下内容将为您提供网址的锚点部分
parent.window.location.hash.substring(1)
这将fH9a
在您的情况下。然后,使窗口滚动到具有该ID的元素。就像是
window.scrollTo(0,document.getElementById("fH9a").offsetTop)
只有它是动态的,并且只要您在页面中具有具有给定id的元素,它就可以与任何锚一起使用。
如下所示,通过此页面传递带有锚点的ID
<a href="http://www.clubedoinferno.com/index.php/store#fH9a">BUY NOW</span></a>
希望能奏效。
编辑
似乎该页面iframe
不是来自同一域。因此上述方法将行不通。
但是如果你更新
<a href="http://www.clubedoinferno.com/index.php/store#fH9a">BUY NOW</span></a>
和
<a href="http://www.clubedoinferno.com/index.php/store?fH9a">BUY NOW</span></a>
和使用
document.referrer.substring(1+document.referrer.indexOf("?"))
代替
parent.window.location.hash.substring(1)
它将(希望)工作。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句