0

ナビゲーションアイコンを左右に修正するために、1つの小さなjQueryコードをサイトに挿入しました。問題は、がクッパウィンドウのサイズを変更した場合にのみ機能することですが、ドキュメントが読み込まれた直後にアイコンを配置する必要があります...ここでこれを実際に見ることができます(ハンガリー語):utravalo.com

このコードは他のサイトでも機能し、問題はありません。私は少し混乱しています...:)

これはjqueryコードです:

if (jQuery) {
  /* obtain jQuery instance */
  $sdv = jQuery.noConflict();

  /* ensure the links look & feel consistent */
  var formatLink = function (strEl) {
          var pEl = $sdv(strEl);
          if (pEl.length > 0) {
              pEl.children().children().css('color', '#3D536C');
              pEl.children().children().hover(

              function () {
                  $sdv(this).css('color', '#444444');
              }, function () {
                  $sdv(this).css('color', '#3D536C');
              });
          }
      }
  formatLink("#divPrev");
  formatLink("#divNext");

  var fnModifyNavigation = function () {
          /* obtain window's width */
          var w = $sdv(window).width();
          var hw = (w - 1020) / 2;
          if (hw > 100) {
              /* we have enough space for the fixed postion links */
              jQFPL($sdv("#divPrev"), 'left', 0, hw);
              jQFPL($sdv("#divNext"), 'right', 0, hw);
              $sdv("#divPostNav").hide();
          } else {
              /* not enough space for the fixed postion links */
              var divNav = $sdv("#divPostNav");
              if (divNav.length > 0) {
                  if (divNav.css('display') == 'none') {
                      divNav.show();
                      divNav.prepend(jQSPL("#divNext", "right"));
                      divNav.prepend(jQSPL("#divPrev", "left"));
                  }
              }
          }
      }

      /* jQuery Fixed Position Link */
  var jQFPL = function (el, remClass, absPosPX, width) {
          var pEl = el.detach();
          if (pEl) {
              pEl.removeClass(remClass);
              eval("var objStyle = { 'position':'fixed', 'top':'250px', 'width': '" + width + "px', '" + remClass + "':'" + absPosPX + "px', 'text-align':'" + remClass + "'};");
              pEl.css(objStyle);
              pEl.appendTo("body");
          }
      }

      /* jQuery Static Position Link*/
  var jQSPL = function (strEl, strFloat) {
          var el = $sdv(strEl).detach();
          el.css('position', 'static');
          el.css('width', '50%');
          el.css('float', strFloat);
          return el;
      }

      /* run position modification routine after the document is loaded */
      $sdv(fnModifyNavigation);

     /* handle the window's resize event and run position modification routine again */
     $sdv(window).resize(fnModifyNavigation);
}

助けてくれてありがとう!!

4

2 に答える 2

1

jQuery ready メソッドで、modify nav と formatLink 関数を実行します (これは、html が読み込まれるのを待ちます)。

$sdv(document).ready(
    function(){

        formatLink("#divPrev");
        formatLink("#divNext");

        /* run position modification routine
        after the document is loaded */
        $sdv(fnModifyNavigation);  

        /* handle the window's resize event
        and run position modification routine again */
        $sdv(window).resize(fnModifyNavigation);
    }
);
于 2012-06-09T09:30:11.937 に答える
0

最後の行を変更し、

から

$sdv(window).resize(fnModifyNavigation);

$sdv(window).resize(fnModifyNavigation).resize();
于 2012-06-09T09:56:06.507 に答える