我正在尝试将用户重定向到页面中的某些部分。
通常,您会将锚标记放在末尾。但因为我们使用的营销系统自动将跟踪链接插入到href中,我似乎无法在链接中放置重定向锚点标记。
例如:
href="www.yahoo.com/#collections"当它通过营销系统时,它就变成了
href="www.yahoo.com/#collections?cid=tracking..."很遗憾,我不能手动编辑此链接。我想知道我们是否可以在链接的不同部分定位锚标签,或者除了锚标签之外,有没有办法添加重定向?
发布于 2017-07-14 21:44:27
只需保留href不变并添加onclick事件:
onclick="window.location.href='#collections'; return false;"也有可能只使用href="#collections“--如果营销软件很好的话,它应该会告诉你这不是一个网址。相反,如果你想链接到一个特定的页面和锚点,使用上面的onclick方法,并使用完整的url和#。如果您的营销软件甚至在onclick中更改了这一点,请尝试javascript字符串连接,如下所示:
onclick="window.location.href='www.yahoo' + '.com' + '#collections'; return false;"
.test
{
height:650px;
width: 450px;
font-size: 50px;
text-align: center;
}<body>
<a href="www.yahoo.com?cid=tracking" onclick="window.location.href='#test4'; return false;">LINK WITH tracking</a>
<div class="test" style="background:red">
<a name="test1"></a>
TEST
</div>
<div class="test" style="background:lightblue">
<a name="test2"></a>
222222222222222 sadsad fsadf
</div>
<div class="test" style="background:pink">
<a name="test3"></a>
3333333 3333 333a sd fasdf asdf
</div>
<div class="test" style="background:yellow">
<a name="test4"></a>
444444 4444 4444444444 sadf sadf
</div>
<div class="test" style="background:grey">
<a name="test5"></a>
555555 sadf sadf
</div>
</body>
https://stackoverflow.com/questions/45104275
复制相似问题