我有一个代码,用于设置hashtag之后的值 即http://www.mydoman.com/adv/#justexample我需要值“justexample” 但我想使用questionmark而不是hashtag: http://www.mydomain.com/adv/?justexample
我需要在此代码中替换:
<script>
jQuery(function($){
setTimeout(function(){
var hash = window.location.hash+"";
var cookieguardada = $.cookie("dv130312_r");
var cookieactual = hash.substring(1);
if((cookieguardada==null && cookieactual!="")||(cookieguardada!=null && cookieactual!="" && cookieguardada!=cookieactual)){
$.cookie("dv130312_r", "-" , { expires: -5, path: "/", domain: "'.$dominioprincipal.'"});
$.cookie("dv130312_r", hash.substring(1) , { expires: 7, path: "/", domain: "'.$dominioprincipal.'"});
}
},500);
});
</script>';
答案 0 :(得分:0)
将window.location.hash
替换为window.location.search
:
<script>
jQuery(function($){
setTimeout(function(){
var queryString = window.location.search+"";
var cookieguardada = $.cookie("dv130312_r");
var cookieactual = queryString.substring(1);
if((cookieguardada==null && cookieactual!="")||(cookieguardada!=null && cookieactual!="" && cookieguardada!=cookieactual)){
$.cookie("dv130312_r", "-" , { expires: -5, path: "/", domain: "'.$dominioprincipal.'"});
$.cookie("dv130312_r", hash.substring(1) , { expires: 7, path: "/", domain: "'.$dominioprincipal.'"});
}
},500);
});
</script>';