【问题标题】:How can the right part of page of Google videos stay still when you search videos on the left当您在左侧搜索视频时,Google 视频页面的右侧部分如何保持静止
【发布时间】:2010-12-13 00:52:58
【问题描述】:

当您使用 Google 视频时,当您在左侧搜索视频时,您会注意到页面的右侧部分保持静止。它是如何实施的?

【问题讨论】:

标签: javascript ajax layout html


【解决方案1】:

使用 ajax

http://www.google.com/search?q=ajax+tutorial

编辑:

function $(id) { return document.getElementById(id); }

function getHTTPObject() {
  var xmlhttp;
  /*@cc_on
  @if (@_jscript_version >= 5)
    try {
      xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
    } catch (e) {
      try {
        xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
      } catch (E) {
        xmlhttp = false;
      }
    }
  @else
  xmlhttp = false;
  @end @*/
  if (!xmlhttp && typeof XMLHttpRequest != 'undefined') {
    try {
      xmlhttp = new XMLHttpRequest();
    } catch (e) {
      xmlhttp = false;
    }
  }
  return xmlhttp;  
}

function AJAX_GetAsinc(ajax, id, url) {
  ajax.abort();
  function statechange() {
    if ((ajax.readyState==4) && (ajax.status==200)) $(id).innerHTML=ajax.responseText;
  }
  ajax.open('GET', url, true);
  ajax.onreadystatechange = statechange;
  ajax.send(null);
}

用法:

var a = getHTTPObject();
AJAX_GetAsinc(a, 'YOUR_DIV_ID', 'mycontent.php');

或:

use jQuery or your favourite framework/library

希望它足够具体

【讨论】:

  • ajax_search.post();ajax_search.onresponse(leftdiv.replace());//任何更详细的内容是特定于实现的,请参阅 GV 页面源代码了解确切详细信息
猜你喜欢
  • 2020-09-09
  • 1970-01-01
  • 1970-01-01
  • 2016-10-17
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2012-06-06
  • 2014-01-01
相关资源
最近更新 更多