微信浏览器无法使用reload()刷新页面 gif图兼容性

本文介绍了在安卓微信浏览器中遇到的页面刷新不更新数据的问题及其解决方案,并分享了关于GIF图片显示兼容性的技巧。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

场景1
 是这样子的,页面有一个ajax请求,在页面上有一个按钮,点击的时候执行window.location.reload(),正常情况reload()后页面依然会向后台发出请求,但在安卓的微信浏览器中reoad后请求的一直是第一次打开页面时请求的数据。没有刷新页面。
解决办法
使用window.location.href=window.location.href+随机数 代替 window.location.reload()。
window.location.href=window.location.href+"?id="+10000*Math.random();

也可以用时间戳代替随机数

window.location.href+"?id="+Date.parse(new Date());
场景2
gif 图片设为背景图在安卓上没有动态效果,苹果可以,
解决办法
只能将gif 图以img标签的形式插入 达到兼容安卓、苹果
这是我的 nginx配置 可以帮我看下是否有问题 , 并且上方回答的代码 安卓重试3次之后 还是加载字体失败 user www www; worker_processes auto; error_log /www/wwwlogs/nginx_error.log crit; pid /www/server/nginx/logs/nginx.pid; worker_rlimit_nofile 100000; stream { log_format tcp_format '$time_local|$remote_addr|$protocol|$status|$bytes_sent|$bytes_received|$session_time|$upstream_addr|$upstream_bytes_sent|$upstream_bytes_received|$upstream_connect_time'; access_log /www/wwwlogs/tcp-access.log tcp_format; error_log /www/wwwlogs/tcp-error.log; include /www/server/panel/vhost/nginx/tcp/*.conf; } events { use epoll; worker_connections 51200; multi_accept on; } http { include mime.types; types { font/truetype ttf; font/opentype otf; font/woff woff; font/woff2 woff2; } #include luawaf.conf; include proxy.conf; default_type application/octet-stream; server_names_hash_bucket_size 512; client_header_buffer_size 32k; large_client_header_buffers 4 32k; client_max_body_size 300m; sendfile on; tcp_nopush on; keepalive_timeout 60; tcp_nodelay on; fastcgi_connect_timeout 3000; fastcgi_send_timeout 3000; fastcgi_read_timeout 3000; fastcgi_buffer_size 64k; fastcgi_buffers 4 64k; fastcgi_busy_buffers_size 128k; fastcgi_temp_file_write_size 256k; fastcgi_intercept_errors on; gzip on; gzip_min_length 1k; gzip_buffers 4 16k; gzip_http_version 1.1; gzip_comp_level 2; gzip_types text/plain application/javascript application/x-javascript text/javascript text/css application/xml; gzip_vary on; gzip_proxied expired no-cache no-store private auth; gzip_disable "MSIE [1-6]\."; limit_conn_zone $binary_remote_addr zone=perip:10m; limit_conn_zone $server_name zone=perserver:10m; server_tokens off; access_log off; server { listen 888; server_name phpmyadmin; index index.html index.htm index.php; root /www/server/phpmyadmin; location ~ /tmp/ { return 403; } #error_page 404 /404.html; include enable-php.conf; location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$ { expires 30d; } location ~* \.(ttf|otf|woff2?)$ { alias /www/wwwroot/yinzhang.jinshelby.com/public/xcx/font/; types {} default_type font/truetype; # CORS配置(已包含您想添加的内容) add_header Access-Control-Allow-Origin * always; # 改为*确保兼容性 add_header Access-Control-Allow-Methods 'GET, OPTIONS' always; add_header Access-Control-Allow-Headers 'Origin,Accept,Range' always; add_header Access-Control-Expose-Headers 'Content-Length' always; add_header Access-Control-Max-Age 86400 always; add_header Vary Origin always; if ($request_method = 'OPTIONS') { return 204; } expires max; access_log off; etag on; } location ~ .*\.(js|css)?$ { expires 12h; } location ~ /\. { deny all; } access_log /www/wwwlogs/access.log; } include /www/server/panel/vhost/nginx/*.conf; }
最新发布
07-05
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值