|
|
百度站长平台链接自动提交-js代码- <script>! J7 K7 w5 `. x
- (function(){6 X* l4 @; j% ^/ O+ q
- var canonicalURL, curProtocol;
5 A6 x4 O, T( m4 \$ O* {# S9 o - //Get the <link> tag
! R+ _& [" y) q( X5 K - var x=document.getElementsByTagName("link");
/ T0 J( t0 Z; u" M- r+ ?" I5 S X - //Find the last canonical URL S4 c/ j" T2 s4 c9 _5 R4 O
- if(x.length > 0){
& a3 ^1 o7 u3 w8 c1 a3 t - for (i=0;i<x.length;i++){& l- C6 L3 N+ u3 H7 ?
- if(x[i].rel.toLowerCase() == 'canonical' && x[i].href){* I$ K2 N' o; t6 j% `
- canonicalURL=x[i].href;7 @: ~6 R& B4 d
- }
+ b& X& X; G) g' ^) L - }; {, w% J) E; X) R$ t3 f
- }: P {9 Y( L" }% ]/ R
- //Get protocol
. E! b7 D3 s' U" |" {2 F* x5 t m - if (!canonicalURL){
' _& g8 N0 @$ A/ j9 c) { - curProtocol = window.location.protocol.split(':')[0];
) d4 ?) i0 D* h+ O% m4 Y - }
' o3 G; o! O/ K2 Q; i" p# i$ q - else{
: }& D. w+ d! T7 d/ A* ^' |* _ - curProtocol = canonicalURL.split(':')[0];- p5 _1 i, N; N8 v$ f" z
- }" S. N0 d* l& g
- //Get current URL if the canonical URL does not exist# B) _- G3 ^% o& a5 r" `0 Q- X5 I8 I
- if (!canonicalURL) canonicalURL = window.location.href;5 p. j) \6 d, l7 J
- //Assign script content. Replace current URL with the canonical URL7 L, `1 A* R) o3 Z
- !function(){var e=/([http|https]:\/\/[a-zA-Z0-9\_\.]+\.baidu\.com)/gi,r=canonicalURL,t=document.referrer;if(!e.test(r)){var n=(String(curProtocol).toLowerCase() === 'https')?"https://sp0.baidu.com/9_Q4simg2RQJ8t7jm9iCKT-xh_/s.gif":"//api.share.baidu.com/s.gif";t?(n+="?r="+encodeURIComponent(document.referrer),r&&(n+="&l="+r)):r&&(n+="?l="+r);var i=new Image;i.src=n}}(window);})();
3 j6 J$ Y2 O+ T! Q+ P% I - </script>
& s1 v/ E) K. Z4 [
复制代码
( v2 @; {# J7 i0 L2 c3 E
- Z9 H, j+ ^1 _, M3 x; m r3 c8 a4 \" t; ~$ u2 G
|
|