programing

페이지 로드 전에 jQuery Mobile에서 Ajax를 비활성화하는 방법

mbctv 2023. 3. 12. 11:09
반응형

페이지 로드 전에 jQuery Mobile에서 Ajax를 비활성화하는 방법

제 모바일 웹사이트에서요.Adsense Mobile 광고를 로드하려고 했는데 페이지가 로드된 후에도 계속 전체 페이지를 차지합니다.

Ajax 를 무효로 하면, 그 페이지는 광고와 함께 정상적으로 로드되는 것을 알았습니다.이 작업은 태그가 있는 링크를 클릭했기 때문에 로드하는 두 번째 페이지에서만 작동합니다.

data-ajax="false"

그럼 다음 페이지가 완벽하게 로딩되죠

문제:adsense ad에 의해 로드된 첫 페이지는 ajax가 유효하기 때문에 덮어쓰게 됩니다(내 생각에).

기본적으로 제 페이지의 첫 부분은 이렇습니다.

<html>
<head>

<link rel="stylesheet" href="http://code.jquery.com/mobile/1.0rc3/jquery.mobile-1.0rc3.min.css" />
<script src="http://code.jquery.com/jquery-1.6.4.min.js"></script>
<script src="http://code.jquery.com/mobile/1.0rc3/jquery.mobile-1.0rc3.min.js"></script>
<script language="text/javascript">

      $(document).bind("mobileinit", function () {

            $.mobile.ajaxEnabled = false;

      });

</script>
</head>
<body>

    <div data-role="header">
        <h1>Angry Birds Cheats</h1>
    </div>



    <div data-role="content">

<div>
    <script type="text/javascript"><!--
  // XHTML should not attempt to parse these strings, declare them CDATA.
  /* <![CDATA[ */
  window.googleAfmcRequest = {
    client: '',
    format: '',
    output: '',
    slotname: '',
  };
  /* ]]> */
//--></script>
<script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_afmc_ads.js"></script>
</div>

코드에서 에이잭스를 비활성화하려고 했지만, 아직 광고가 전체 페이지를 차지하기 때문에 그런 것 같지는 않아요.

방문자를 특정 페이지에서 시작하여 Ajax가 아닌 페이지로 리디렉션할 수 있지 않을까 생각했습니다.

하여 에 할 수 있습니다.mobileinit이벤트 : http://jquerymobile.com/demos/1.0/docs/api/globalconfig.html

특히 이 비트:

mobileinit 이벤트는 실행 즉시 트리거되므로 jQuery Mobile을 로드하기 전에 이벤트 핸들러를 바인드해야 합니다.

, 하다, 하다, 하다, 하다, 하다, 하다, 하다, 하다, 하다, 하다, 하다, 하다, , 하다, 하다, 하다, 하다, 하다, 하다, 하다, 하다, 하다, 하다, 하다, 하다, 하다, 하다, 하다, 하다, 하다, 하다, 하다.mobileinit 이벤트 표시:

<link rel="stylesheet" href="http://code.jquery.com/mobile/1.0rc3/jquery.mobile-1.0rc3.min.css" />
<script src="http://code.jquery.com/jquery-1.6.4.min.js"></script>
<script type="text/javascript">
$(document).bind("mobileinit", function () {
    $.mobile.ajaxEnabled = false;
});
</script>
<script src="http://code.jquery.com/mobile/1.0rc3/jquery.mobile-1.0rc3.min.js"></script>

번째 Core( jQuery Core(JQuery Core)).bind()수 있게 됩니다.) 그 에 사용 가능합니다.mobileinit 핸들러, 파일이므로 jQuery Mobile js의 ).mobileinit

하고 있는 것이 어떤 해 볼 수 있습니다.mobileinit가 "이벤트 핸들러"를 하지 않습니다.alert수에있있 있있있다다

업데이트된 jQuery Mobile 매뉴얼은 http://jquerymobile.com/test/docs/api/globalconfig.html를 참조하십시오.

jQuery 및 jQuery UI와 같은 다른 jQuery 프로젝트와 달리 jQuery Mobile은 로드되는 즉시(document.ready 이벤트가 발생하기 훨씬 전) 많은 마크업 확장을 자동으로 적용합니다.이러한 향상 기능은 일반적인 시나리오에서 작동하도록 설계된 jQuery Mobile의 기본 설정을 기반으로 적용됩니다.설정을 변경할 필요가 있는 경우는, 간단하게 설정할 수 있습니다.

mobileinit 이벤트

jQuery Mobile이 시작되면 문서 오브젝트에서 mobileinit 이벤트가 트리거됩니다.기본 설정을 덮어쓰려면 mobileinit에 바인드합니다.

$(document).on("mobileinit", function(){
  //apply overrides here
});

mobileinit 이벤트는 즉시 트리거되므로 jQuery Mobile을 로드하기 전에 이벤트 핸들러를 바인드해야 합니다.다음 순서로 JavaScript 파일에 링크합니다.

<script src="jquery.js"></script>
<script src="custom-scripting.js"></script>
<script src="jquery-mobile.js"></script>

jQuery의 $.extend 메서드를 사용하여 $.mobile 개체를 확장하여 기본 설정을 재정의할 수 있습니다.

$(document).on("mobileinit", function(){
  $.extend(  $.mobile , {
    foo: bar
  });
});

또는 오브젝트 속성 표기법을 사용하여 설정할 수 있습니다.

$(document).on("mobileinit", function(){
  $.mobile.foo = bar;
});

jquery mobile ajax 동작을 이해하는 데 도움이 되는 페이지

http://jquerymobile.com/test/docs/pages/page-links.html

애니메이션 페이지 전환을 활성화하기 위해 외부 페이지(예: products.html)를 가리키는 모든 링크가 Ajax를 통해 로드됩니다.

다른 도메인을 가리키거나 rel="false", data-false="false" 또는 대상 특성이 있는 링크는 Ajax와 함께 로드되지 않습니다.대신, 이러한 링크는 애니메이션 전환 없이 전체 페이지를 새로 고칩니다.속성(rel="false" 및 data-false="false")은 모두 동일한 효과가 있지만 다른 사이트 또는 도메인에 링크할 때는 다른 의미인 rel="false"를 사용해야 하며, data-false="는 도메인 내의 페이지가 Ajax를 통해 로드되지 않도록 선택하는 데 유용합니다.

Anchor 태그의 data-module="false"를 사용하면 페이지당 솔루션을 비활성화할 수 있습니다.

언급URL : https://stackoverflow.com/questions/8684234/how-to-disable-ajax-in-jquery-mobile-before-page-load

반응형