Giter Club home page Giter Club logo

web_learn's Introduction

WEB_learn

web相关的学习,包括:

  • JavaScript
  • HTML/5+CSS
  • PHP

web_learn's People

Contributors

bfchengnuo avatar

Stargazers

lijunwei avatar  avatar  avatar

Watchers

 avatar

web_learn's Issues

Html文件中如何引入Html?

JS 方式

先将你的 html 转换成 js 的形式,在线转换网站:http://www.css88.com/tool/html2js/

转好之后自定义个 xx.js 文件中写 var header = 你转好的内容
然后在 a.html 中首先引用 xx.js 文件,在 a.html 要用到的地方写上

<script type="text/javascript">
  window.onload=function(){
    document.write(header);
  }
</script> 

这样就可以将一个网站的头尾分离出来了。

使用JS的ajax请求方式

出自:https://www.w3schools.com/howto/howto_html_include.asp

1.要引入的 html 文件:content.html

<a href="howto_google_maps.asp">Google Maps</a><br>
<a href="howto_css_animate_buttons.asp">Animated Buttons</a><br>
<a href="howto_css_modals.asp">Modal Boxes</a><br>
<a href="howto_js_animate.asp">Animations</a><br>
<a href="howto_js_progressbar.asp">Progress Bars</a><br>
<a href="howto_css_dropdown.asp">Hover Dropdowns</a><br>
<a href="howto_js_dropdown.asp">Click Dropdowns</a><br>
<a href="howto_css_table_responsive.asp">Responsive Tables</a><br>

2.在要引入的页面加入 <div w3-include-html="content.html"></div>

3.定义一个 js 文件,并且将其引入:

function includeHTML() {
  var z, i, elmnt, file, xhttp;
  /*loop through a collection of all HTML elements:*/
  z = document.getElementsByTagName("*");
  for (i = 0; i < z.length; i++) {
    elmnt = z[i];
    /*search for elements with a certain atrribute:*/
    file = elmnt.getAttribute("w3-include-html");
    if (file) {
      /*make an HTTP request using the attribute value as the file name:*/
      xhttp = new XMLHttpRequest();
      xhttp.onreadystatechange = function() {
        if (this.readyState == 4) {
          if (this.status == 200) {elmnt.innerHTML = this.responseText;}
          if (this.status == 404) {elmnt.innerHTML = "Page not found.";}
          /*remove the attribute, and call this function once more:*/
          elmnt.removeAttribute("w3-include-html");
          includeHTML();
        }
      } 
      xhttp.open("GET", file, true);
      xhttp.send();
      /*exit the function:*/
      return;
    }
  }
}

4.在要引入文件的页面调用这个方法:

<script>
  includeHTML();
</script>

相当于是发了一个异步请求~

npm设置代理

npm 国内的速度真是慢到令人发指...

开 ss 全局还没用,手动设置 npm 的代理试试

npm config set strict-ssl false
npm config set proxy=http://127.0.0.1:1080
npm config set https-proxy http://127.0.0.1:1080
npm config set registry "http://registry.npmjs.org/"

最后你可以删除这些配置:

npm config delete http-proxy
npm config delete https-proxy

当然,为什么不直接用 cnpm 呢?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.