开发者

How to reset counter number on page refresh in Firefox with jQuery?

开发者 https://www.devze.com 2023-04-13 01:20 出处:网络
I\'m noticed it is a bug or not... then other browsers like Chrome and Opera can reset counter number, but Firefox doesn\'t reset it...

I'm noticed it is a bug or not... then other browsers like Chrome and Opera can reset counter number, but Firefox doesn't reset it...

Go to http://bksn.mx/opequimar/renta_descripcion.html

There a web page and go to thumbnails section, click right arrows until is maximum number, then refresh page (F5) and you see "3 de 3", try it again and you will see "5 de 3" with Firefox.

The first number is counter and the last number is size(); each to div of thumbnails.

There a script of number counter:

$("a.prevarrow1").click("click", function() {
  var qInput = $(this).parents(".quantityInput");
  var qText = qInput.find(".quantityText");
  var qValue = parseInt((qText.val())? qText.val()开发者_运维问答 : 0);
  qText.val(Math.max(qValue - 1, (qInput.attr("min"))? qInput.attr("min") : -0xffff));
});

$("a.nextarrow1").click("click", function() {
  var qInput = $(this).parents(".quantityInput");
  var qText = qInput.find(".quantityText");
  var qValue = parseInt((qText.val())? qText.val() : 0);
  qText.val(Math.min(qValue + 1, (qInput.attr("max"))? qInput.attr("max") : 0xffff));
});

HTML of output:

<div class="quantityInput" min="0" max="64">
<p>Pags. &nbsp;
    <input type="text" disabled="disabled" class="quantityText" value="1" />
   de &nbsp;<span></span></p>
<div class="absolute">
   <a class="prev prevarrow1"></a>

<a class="next nextarrow1"></a>
   </div>
</div>

If is not possible, i accept the new scripts from yours. Thanks in advance!


The issue is that the page number is stored in a textbox. Firefox, IE, and "Browsers going back to Netscape 1 (and almost certainly NCSA Mosaic)" according to Brendan Eich restore saved form data on reload, but not on shift-reload. Webkit-based browsers are indeed incompatible here.

The solution is to avoid using a textbox to display the number (change it to a <span>, change the span's value with jQuery's .text()) or to read the input's value on load and update the page's state appropriately (scrolling the thumbnails to the specified page number).

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号