帮帮我:使用JScript查询 [英] Help me: Querystring with JScript

查看:87
本文介绍了帮帮我:使用JScript查询的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道变量variabletopass的语法。在ASP:


www.destinationpage.asp?variable =<%= variabletopass%>


什么是语法Javascript?


Thks

I know the syntax for variable "variabletopass" in ASP:

www.destinationpage.asp?variable=<%=variabletopass %>

What''s the syntax for Javascript?

Thks

推荐答案

Fabioaécrit:
Fabio a écrit :

我知道变量variabletopass的语法。在ASP:
I know the syntax for variable "variabletopass" in ASP:



但我不知道asp

But I don''t know asp


www.destinationpage.asp?variable =<%= variabletopass%>


Javascript的语法是什么?
www.destinationpage.asp?variable=<%=variabletopass %>

What''s the syntax for Javascript?



发送变量:


location.href ='''www.destinationpage.asp?variable =''+ myVariable ;

to querry string:


var url = self.location.search;


//将返回:''?variable = trucmachinchose''


使用单独的变量获取值:


myVariable = url.split(''= '')[1];

ie:


< body onload =" alert(''variable =''+ self.location.search .split(''='')[1])">

如何处理几个变量(直接脚本):


< html>

< script type =" text / javascript">

var url = self.location.search.toString();

if(url.indexOf(''?'')== 0){

url = url.substring(1)

if(url.indexOf (''&'')> 0)

{

var vars = url.split(''&'');

for(var i = 0; i< vars.le ngth; i ++)

{

var v = vars [i] .split(''='');

alert(v [ 0] +''=''+ v [1]);

eval(v [0] +''="''+ v [1] +''"'') ;

}

}

其他

myVariable = url.split(''='')[1 ];

}

< / script>

< body onload =" alert(''variable =''+ self。 location.search.split(''='')[1])">


< a href ="?">示例零< / a>

< a href ="?avar = ASM">示例一< / a>

< a href ="?avar = ASM& Name = Moriaux& Surname = Stephane"> example 2< / a>

< a href ="#"

onclick =" if(typeof(myVariable) )!=''undefined'')

alert(''myVariable =''+ myVariable);

else

if(typeof( vars)!=''undefined'')

alert(''name =''+ Name);

else alert(''no vari能够'');

返回false;"> control< / a>

< / body>

< / html> ;


-

Stephane Moriaux et son(moins)vieuxMacdéjàdépassé

To send variable :

location.href = ''www.destinationpage.asp?variable=''+myVariable;
To querry string :

var url = self.location.search;

// will return : ''?variable=trucmachinchose''

To get value with an alone variable :

myVariable = url.split(''='')[1];
i.e. :

<body onload="alert(''variable = ''+self.location.search.split(''='')[1])">
How I do with several variables (direct script in head) :

<html>
<script type="text/javascript">
var url = self.location.search.toString();
if(url.indexOf(''?'')==0) {
url = url.substring(1)
if(url.indexOf(''&'')>0)
{
var vars = url.split(''&'');
for(var i=0; i<vars.length; i++)
{
var v = vars[i].split(''='');
alert(v[0]+'' = ''+v[1]);
eval(v[0] +''="'' + v[1] + ''"'');
}
}
else
myVariable = url.split(''='')[1];
}
</script>
<body onload="alert(''variable = ''+self.location.search.split(''='')[1])">

<a href="?">example zero</a>
<a href="?avar=ASM">example one</a>
<a href="?avar=ASM&Name=Moriaux&Surname=Stephane">exa mple two</a>
<a href="#"
onclick="if(typeof(myVariable)!=''undefined'')
alert(''myVariable = ''+myVariable);
else
if(typeof(vars)!=''undefined'')
alert(''name = ''+Name);
else alert(''no variable'');
return false;">control</a>
</body>
</html>

--
Stephane Moriaux et son (moins) vieux Mac déjà dépassé


Ok ,我明白了。

但是如何在框架中定位我的链接?字符串:


onclick =" parent.FRAMEDESTINATION.location.href = ..


不起作用(FRAMEDESTINATION未定义)


Thks
Ok, I got it.
But how can I target my link in a frame? The string:

onclick="parent.FRAMEDESTINATION.location.href=..

doesn''t work ("FRAMEDESTINATION is not defined")

Thks


Fabioaécrit:
Fabio a écrit :

好​​的,我明白了。

但是我如何在框架中定位我的链接?字符串:


onclick =" parent.FRAMEDESTINATION.location.href = ..


不起作用(FRAMEDESTINATION未定义)
Ok, I got it.
But how can I target my link in a frame? The string:

onclick="parent.FRAMEDESTINATION.location.href=..

doesn''t work ("FRAMEDESTINATION is not defined")



所以你要定义它...没有?


< frame name =" ; FRAMEDESTINATION" ...>


警告:姓名而不是ID!


无论如何,最好将JS文件显示在正确的框架中。

-

Stephane Moriaux et son(moins)vieuxMacdéjàdépassé

Stephane Moriaux和他的(较少)旧Mac已经过时了

so you have do define it ... no ?

<frame name="FRAMEDESTINATION" ... >

caution : name and not id !

Anyway, better to have the JS in file displayed in correct frame.
--
Stephane Moriaux et son (moins) vieux Mac déjà dépassé
Stephane Moriaux and his (less) old Mac already out of date


这篇关于帮帮我:使用JScript查询的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆