GET data is thrown into page on document load
This question already has an answer here:
如果设置了$_GET['ok']
,那么您可以使用PHP进行检查,然后将其回显为JavaScript变量:
var ok = <?php echo intval(isset($_GET['ok'])) ?>
You can use the following which was taken from How to get the value from URL Parameter?
var QueryString = function () {
// This function is anonymous, is executed immediately and
// the return value is assigned to QueryString!
var query_string = {};
var query = window.location.search.substring(1);
var vars = query.split("&");
for (var i=0;i<vars.length;i++) {
var pair = vars[i].split("=");
// If first entry with this name
if (typeof query_string[pair[0]] === "undefined") {
query_string[pair[0]] = pair[1];
// If second entry with this name
} else if (typeof query_string[pair[0]] === "string") {
var arr = [ query_string[pair[0]], pair[1] ];
query_string[pair[0]] = arr;
// If third or later entry with this name
} else {
query_string[pair[0]].push(pair[1]);
}
}
return query_string;
} ();
then you can check if $_GET['ok'] is present in url with:
if(query_string.ok !== undefined){
//$_GET['ok'] is in url
}
链接地址: http://www.djcxy.com/p/17620.html
上一篇: 为什么Arrays.asList()返回自己的ArrayList实现
下一篇: 在文件加载时,GET数据被扔进页面