Help me: Querystring with JScript

A

ASM

Fabio a écrit :
I know the syntax for variable "variabletopass" in ASP:

But I don't know asp
www.destinationpage.asp?variable=<%=variabletopass%>

What's the syntax for Javascript?

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.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">example 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>
 
F

Fabio

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
 
A

ASM

Fabio a écrit :
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")

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.
 
F

Fabio

<frame name="FRAMEDESTINATION" ... >

caution : name and not id !


It doesn't work: the target frame has its name, "centro", but I've the same
error:

"parent.centro.location is null or not object"

What can I do?

Thks
 
F

Fabio

It doesn't work, because I need to target the link to a frame ("center") of
another open window, NOT to a frame of the same window. What can I do?

My string is:

<span class="rosso"
onclick="parent.center.href='frame_ricercamusica_responso.asp?parolachiave='
+keyword; return false">Click here!</span>

Thks.

Fabio
 
A

ASM

Fabio a écrit :
It doesn't work, because I need to target the link to a frame ("center") of
another open window, NOT to a frame of the same window. What can I do?

Più forte del Roquefort !

Say you did open your popup :
popi = window.open( ... );

Perhaps this could work :

onclick="popi.center.href='frame_ricercamusica_responso.asp?parolachiave='
+keyword; return false">Click here! said:
<span class="rosso"
onclick="parent.center.href='frame_ricercamusica_responso.asp?parolachiave='
+keyword; return false">Click here!</span>

La prossima volta si attacca il parmigiano.
 
F

Fabio

Cerco di essere più preciso

Prima finestra: 3 frames:
"sinistro"
"centro"
"destro"

Cliccando su un bottone del frame sinistro si apre una popup di nome
"orra". Questa popup è divisa in 2 frames: "alto" e "basso"

Nel frame "basso" di questa popup c'è un link che dovrebbe farmi aprire una
pagina nel frame
"centro" della prima

Spero sia stato chiaro :) Grazie

Fabio
 
A

ASM

Fabio a écrit :
Cerco di essere più preciso

Si nuota nel formaggio bianco :)
Prima finestra: 3 frames:
"sinistro"
"centro"
"destro"

Cliccando su un bottone del frame sinistro si apre una popup di nome
"orra". Questa popup è divisa in 2 frames: "alto" e "basso"

Nel frame "basso" di questa popup c'è un link che dovrebbe farmi aprire una
pagina nel frame
"centro" della prima

You could try :

parent.opener.centro.location = 'laMiaMeravigliosaPagina.htm'
Spero sia stato chiaro :) Grazie

In francese questo mi avesse l'avuto potuto :)

HTH
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,537
Members
45,021
Latest member
AkilahJaim

Latest Threads

Top