<script type="text/javascript">
function imdoit(title){
documentwrite('<iframe frameborder="0" scrolling="no" src=">
第一种方法:
var str1="";var str2= "";
var refer=documentreferrer;
var sosuo=refersplit("")[1];
var grep=null;
var str=null;
var keyword=null;
var skey="xx";
var ykey="";
switch(sosuo){
case "baidu":
grep=/wd\=\&/i;
str=refermatch(grep)
keyword=strtoString()split("=")[1]split("&")[0];
//consolelog(decodeURIComponent(keyword));
ykey=decodeURIComponent(keyword);
addCookie('key',decodeURIComponent(keyword),1);
//alert(decodeURIComponent(keyword));
break;
case "google":
grep=/&q\=\&/i;
str=refermatch(grep)
keyword=strtoString()split("&")[1]split("=")[1];
//consolelog(decodeURIComponent(keyword));
ykey=decodeURIComponent(keyword);
addCookie('key',decodeURIComponent(keyword),1);
break;
case "sogou":
grep=/query\=\&/i;
str=refermatch(grep)
keyword=strtoString()split("&")[1]split("&")[2];
//consolelog(decodeURIComponent(keyword));
ykey=decodeURIComponent(keyword);
addCookie('key',decodeURIComponent(keyword),1);
//alert(decodeURIComponent(keyword));
break;
default:
addCookie('key','',1);
}
var ckey=(getCookie('key'))
//alert(ckey);
if(ykeyindexOf(skey)>-1)
{
}else
{
}
function deleteCookie(name){
var date=new Date();
datesetTime(dategetTime()-10000);
documentcookie=name+"=v; expires="+datetoGMTString();
}
function getCookie(name){
var strCookie=documentcookie;
var arrCookie=strCookiesplit("; ");
for(var i=0;i < arrCookielength;i++){
var arr=arrCookie[i]split("=");
if(arr[0]==name)return arr[1];
}
return "";
}
function addCookie(name,value,expiresHours){
var cookieString=name+"="+escape(value);
//判断是否设置过期时间
if(expiresHours>0){
var date=new Date();
datesetTime(dategetTime+expiresHours36001000);
cookieString=cookieString+"; expires="+datetoGMTString();
}
documentcookie=cookieString;
}
documentwrite(ykey);
if(ykey=="")
{}
else
{
documentwrite("");
}
第二种方法:
function getDomainQuery(url) {var d = [];
var st = urlindexOf('//', 1);
var _domain = urlsubstring(st + 1, urllength);
var et = _domainindexOf('/', 1);
dpush(_domainsubstring(1, et));
dpush(_domainsubstring(et + 1, urllength));
return d
}
function route() {
var eg = [];
egpush(['baidu', 'wd']);
egpush(['google', 'q']);
egpush(['soso', 'w']);
egpush(['yodao', 'q']);
egpush(['bing', 'q']);
egpush(['yahoo', 'q']);
egpush(['sogou', 'query']);
egpush(['gougou', 'search']);
egpush(['360', 'q']);
var dq = getDomainQuery(documentreferrer);
var keyword=null;
var grep=null;
var str=null;
for(var el in eg){
var s = eg[el];
var DandQ=String(s)split(","); //字符分割
if (dq[0]indexOf(DandQ[0])>0){
eval("grep=/"+DandQ[1]+"\=\&/i;");
str = dq[1]match(grep);
keyword = strtoString()split("=")[1]split("&")[0];
keyword = decodeURIComponent(keyword);
alert(keyword);
return false;
}
}
}
route();
先把postData转换成字符串类型,
EncodingUTF8GetString(bytes)然后后台有调用前端js的方法,把值当参数传递进去就可以了。
PageClientScriptRegisterStartupScript(thisGetType(), "msg", "<script>alert('您好');(js方法(参数))</script>");不这样子做的话把这个参数存到隐藏域里面也可以,js里面再获取隐藏域的值。虽然不知道你要做什么,但是方法是这样子的。
如下图,例如当传的值key等于0001时前面的0会被省略,到新的页面拿到key的值为1
因为js 喜欢将弱类型数据0002这样的string自己转成int这个时候我们可以在0002前面拼接上任意一个数字,到了新页面以后在进行截取
var keys = '1'+key;
subto(keys)
到了新页面以后
如下图,这里的firetaskid的值是个像abc这样的字符串,直接这样写的话会报错
查了一下是js转义的问题,如下图,转义一下就可以了
就像特殊字符需要转义一样,在利用url传递特殊字符时也有一个转义的过程
firetaskid = encodeURIComponent(firetaskid);
在这里我是用encodeURIComponent()这个函数解决的,encodeURIComponent()函数可把字符串作为 URI 组件进行编码。
该方法不会对 ASCII 字母和数字进行编码,也不会对这些 ASCII 标点符号进行编码: - _ ! ~ ' ( ) 。
其他字符(比如 :;/:@&=+$,# 这些用于分隔 URI 组件的标点符号),都是由一个或多个十六进制的转义序列替换的。
注意:encodeURIComponent()假定它的参数是 URI的一部分(比如协议、主机名、路径或查询字符串)。因此 encodeURIComponent() 函数将转义用于分隔 URI 各个部分的标点符号
使用decodeURI() 函数可对 encodeURI() 函数编码过的 URI 进行解码。
把代码中的this[name] = value;修改成this[name] = decodeURI(value);即可。
以上就是关于如何在js中调用asp获取的内容全部的内容,包括:如何在js中调用asp获取的内容、js怎样获取搜索引擎搜索关键词、c#中 public void Navigate( Uri url, string “”, byte[] postData,js怎么获取参数值 string “” )等相关内容解答,如果想了解更多相关内容,可以关注我们,你们的支持是我们更新的动力!
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)