2012-04-13 3 views
-2

я сталкиваюсь с проблемой в следующем коде, который используется для загрузки внешней страницы в оверлей, когда пользователь нажимает на кнопкуЗагрузите внешнюю страницу в накладкой

 <!DOCTYPE html> 
     <html> 
      <head> 
       <title>jQuery Tools standalone demo</title> 

       <script src="http://cdn.jquerytools.org/1.2.7/full/jquery.tools.min.js"></script> 


       <style> 

        /* the overlayed element */ 
        .apple_overlay { 

         /* initially overlay is hidden */ 
         display:none; 

         /* growing background image */ 
         background-image:url(images/white.png); 

         /* 
          width after the growing animation finishes 
          height is automatically calculated 
         */ 
         width:640px; 

         /* some padding to layout nested elements nicely */ 
         padding:35px; 

         /* a little styling */ 
         font-size:11px; 
        } 

        /* default close button positioned on upper right corner */ 
        .apple_overlay .close { 
         background-image:url(images/close.png); 
         position:absolute; right:5px; top:5px; 
         cursor:pointer; 
         height:35px; 
         width:35px; 
        } 
       </style> 
      </head> 

      <body> 
       <!-- external page is given in the href attribute (as it should be) --> 
       <a href="http://www.facebook.com/" rel="#overlay" style="text-decoration:none"> 
        <!-- remember that you can use any element inside the trigger --> 
        <button type="button">Show external page in overlay</button> 
       </a> 

       <!-- another link. uses the same overlay --> 
       <a href="http://jquerytools.org/demos/overlay/external-content.htm" rel="#overlay" style="text-decoration:none"> 
        <button type="button">Show another page</button> 
       </a> 

       <!-- overlayed element --> 
       <div class="apple_overlay" id="overlay"> 
        <!-- the external content is loaded inside this tag --> 
        <div class="contentWrap"></div> 
       </div> 

       <!-- make all links with the 'rel' attribute open overlays --> 
       <script> 
        $(function() { 

         // if the function argument is given to overlay, 
         // it is assumed to be the onBeforeLoad event listener 
         $("a[rel]").overlay({ 

          mask: 'darkred', 
          effect: 'apple', 

          onBeforeLoad: function() { 

           // grab wrapper element inside content 
           var wrap = this.getOverlay().find(".contentWrap"); 

           // load the page specified in the trigger 
           wrap.load(this.getTrigger().attr("href")); 
          } 

         }); 
        }); 
       </script> 
      </body> 
     </html> 

этот код взят из http://jquerytools.org/demos/overlay/external.html любой идеи, пожалуйста?

ответ

2

От jQuery documentation:

Из-за ограничений безопасности браузера, большинство запросов «Ajax» могут быть одной и той же политики происхождения; запрос не может успешно извлекать данные из другого домена, субдомена или протокола.

+0

Это ошибка, которую я получил от консоли хром. XMLHttpRequest не может загрузить http://www.facebook.com/. Происхождение null не разрешено Access-Control-Allow-Origin. что я должен сделать, чтобы получить данные успешно? – user1212009

+0

Вы не можете загружать страницы с других сайтов с помощью AJAX. Это функция безопасности. –

+0

@llia: Я ценю ваши усилия, чтобы помочь мне, спасибо вам, llia , но означает ли ваш ответ, что для моего кода нет решения? – user1212009

Смежные вопросы