誰か助けてください。ページの上からスクロールする前に、ページがアンカーに点滅する
私は1ページにいくつかの隠しセクションと、これらのセクションにリンクして表示する一連の他のページを持っています。もともと、ページはちょうどアンカーにまっすぐジャンプしましたが、ページを上からセクションにスクロールする場所にしました。問題は、ページがページの上部にジャンプしてからスクロールする前に、アンカーに少しジャンプしてしまうことです。私が見てきた
<h4 class="blueToggle" onclick="toggle('inventoryPriceMaintenance')">An Incorrect Setting in Inventory Price Maintenance<a id="arrowinventoryPriceMaintenance">▼</a></h4>
<div id="inventoryPriceMaintenance" class="hiddencontent">
<p style="margin-left: 2em; margin-bottom: .3em;">Navigate to the back-screen</p>
<a href="http://204.128.208.7/wp-content/uploads/auto-transfer-7.png"><img class="aligncenter" src="http://204.128.208.7/wp-content/uploads/auto-transfer-7.png" alt="" width="85%" height="85%" /></a>
<p style="text-align: justify; margin-left: 2em; line-height: 1.5em; margin-bottom: .625em;">The item will not be included on automatically generated transfers to a store if the second character in the fourth column (<strong>COMP</strong>) is…</p>
<ul style="margin-left: 5em; line-height: 1.5em;">
<li><strong>D</strong> = discontinued (an item cannot be transferred to a store at which it is discontinued, but it can be transferred from that store)</li>
<li><strong>S</strong> = special order</li>
<li><strong>X</strong> = item has been discontinued everywhere (only relevant at store 00)</li>
</ul>
<p style="text-align: justify; margin-left: 2em;">An item will not auto-transfer if it is not authorized at the specific store</p>
<p style="text-align: justify; margin-left: 5em; line-height: 1.5em; margin-top: -1em; margin-bottom: 0px">Go to the back-screen and see if the store is on the list (a list of authorized stores can also be found on the Inventory Inquiry screen)</p>
<h4 class="blueToggle" onclick="toggle('inventoryPriceMaintenance')" style="margin-top: .3em">Hide -</h4>
</div>
:
ここ<p><a href="http://204.128.208.7/automated-transfers-users/#inventoryPriceMaintenance">Effect on Auto-Transfers</a></p>
は、それがリンクしたページの一部である:ここで
function toggle(id) {
var element = document.getElementById(id);
var text = document.getElementById("arrow" + id);
if (element) {
var display = element.style.display;
if (display == "none" || display == '') {
element.style.display = "block";
text.innerHTML = "▲";
} else {
element.style.display = "none";
text.innerHTML = "▼";
}
}
};
jQuery(document).ready(function() {
jQuery(window.location.hash).show();
if (window.location.hash) {
setTimeout(function() {
jQuery('html, body').scrollTop(0,0).show();
jQuery('html, body').animate({
scrollTop: jQuery(window.location.hash).offset().top
-75}, 1000)
}, 0);
}
});
が1ページである:ここでは
は私のコードです解決策を探し、e.preventDefault()を試しました。偽を返すが、どちらもうまくいっていないし、他に何を試していいのかわからない。
ブラウザはアンカーの位置に移動します。私はあなたがJSでそれを取り消すことはできないと信じていますが、クエリー文字列、または存在しないアンカーを使用して回避することもできます(そして、JSは関連するものを解決できます) – DBS
アンカーは、存在しない? – Erin
など。あなたのページには '#thisAnchor'がありますが、' .com#this'にリンクすればJSは 'window.location.hash +" Anchor "'のようなことをして実際のアンカーを取得します。このようにしてブラウザはページを移動しません( '#this'は存在しません)が、一貫した最終部分を追加することを知っているので、あなたのJSはまだ移動することができます。 – DBS