zoukankan      html  css  js  c++  java
  • [总结帖]Web小白的基础恶补帖

    1. jQuery实现按钮点击跳转网页

        <script src="js/jquery/jQuery-2.2.0.min.js" type="text/javascript" charset="utf-8"></script>
        <script type="text/javascript">
            jQuery("#loginBtn").click(function(){
                location.href="index.html";
            });
        </script>

    * 我第一次用jQuery的时候居然忘了引入jQuery.js,然后各种找不到原因。。

    扩展:>>> PHP实现页面跳转 

    >>> js实现页面跳转

     

    2. >>> HTML中表单的作用

     

    3. 关于跨域问题

    JavaScript跨域总结与解决办法

    http://www.cnblogs.com/rainman/archive/2011/02/20/1959325.html

    PHP AJAX JSONP实现跨域请求使用实例

    http://www.cnblogs.com/xcxc/p/3729660.html

    PHP Ajax 跨域问题最佳解决方案

    http://blog.csdn.net/denghejing/article/details/51731760

    总之,在PHP端,加一句:

    header('Access-Control-Allow-Origin: *');

    然后……就没有然后了。。。

     

    关于Openresty的跨域配置:http://blog.csdn.net/wuxiangege/article/details/52238968

    不知道Openresty为何物?问谷哥度娘^ ^

    server {
            listen       80;
            server_name  localhost;
    
            location / {
                #解决跨域问题
                if ($request_method = 'OPTIONS') {
                    add_header 'Access-Control-Allow-Origin' '*';
                    add_header 'Access-Control-Allow-Headers' 'Content-Type';
                    return 204;
                }   
                if ($request_method = 'POST') {
                    add_header 'Access-Control-Allow-Origin' '*';
                }   
    
                #处理业务的文件
                default_type text/html;
                content_by_lua_file './lua_script/app.lua'; 
            }
    
            error_page   500 502 503 504  /50x.html;
            location = /50x.html {
                root   html;
            }
        }

     

    4. 运用JS设置cookie、读取cookie、删除cookie

    http://www.cnblogs.com/fishtreeyu/archive/2011/10/06/2200280.html

    5. PHP设置Cookie,由js读取

     http://www.cnblogs.com/wangkongming/archive/2013/01/04/2844632.html

    // 第3、4个参数很重要
    setcookie("account", $username, time() + 3600, "/");
    function getCookie(key){  
    	alert(JSON.stringify(document.cookie));
        var arr = document.cookie.match(new RegExp("(^| )"+key+"=([^;]*)(;|$)"));  
        if(arr != null){  
         	return unescape(arr[2]);   
        }else{  
         	return null;  
        }
    }
    

    6. JS动态控制form表单的action行为

    http://blog.csdn.net/w709854369/article/details/6261624

     <form name="form1" action=""> 
          <input type="button" value="action1" onclick="form1.action='1';form1.submit();"> 
          <input type="button" value="action2" onclick="form1.action='2';form1.submit();"> 
     </form>

     

    特别推荐:ionic开发篇之那些年我们踩过的坑

    http://blog.csdn.net/yourlin/article/details/48268361

  • 相关阅读:
    [Python] 登录人人网2011版
    [WPF] 自定义窗体样式
    [Python] 控制台输入密码的方法
    [Python] 字符串加密解密
    [WPF] 模仿AMD LIVE! EXPLORER界面
    [Python] Visual Studio 2008 集成 IronPython 开发环境
    mysql表类型(存储引擎)
    logstash收集nginx访问日志
    linux设置开机启动脚本
    logstash安装log4j插件
  • 原文地址:https://www.cnblogs.com/itfantasy/p/6016432.html
Copyright © 2011-2022 走看看