location.replace in a function

J

Jean Pierre Daviau

Hi everybody,


I have this function in a page (namely cours.html)

function go(inValue)
{
var lien =
'file:///F:/MyWebs/jeanpierredaviaucom/httpdocs/cours1.html?T1=' +
document.R.T1.value;
document.location.replace = "lien";
}


If I put an alert(lien), the link is ok. But when I try it I see
'file:///F:/MyWebs/jeanpierredaviaucom/httpdocs/cours.html?T1=' +
document.R.T1.value; in the address bar (the 1 dissappear and I have the
url of the page in wich the function is.)


--

X trême newbe
.......
masm32
windows Xp
asus p4 s533/333/133
Intel(R) Celeron (R) CPU 2.00 GHz
 
J

Jean Pierre Daviau

Randy Webb said:
Jean Pierre Daviau said the following on 11/27/2005 3:01 PM: there is a mistake here

document.location.replace(lien)

<URL:
http://msdn.microsoft.com/library/d...op/author/dhtml/reference/methods/replace.asp
If I put an alert(lien), the link is ok. But when I try it I see
cours.html?T1=thevalue in the address bar (the 1 dissappear and I have
the url of the page in wich the function is.


I tried theese two ways without success.

function go(inValue){
document.location.replace('cours1.html?T1=' + document.R.T1.value)
}

<form name="R" onSubmit="history.go(document.location.href =
'cours1.html?T1=' + document.R.T1.value);">
 
T

Thomas 'PointedEars' Lahn

Jean said:
I tried theese two ways without success.

function go(inValue){
document.location.replace('cours1.html?T1=' + document.R.T1.value)
}

<form name="R" onSubmit="history.go(document.location.href =
'cours1.html?T1=' + document.R.T1.value);">

history.go() expects a number as argument, indicating how far to go back
(less than zero) or forward (greater than zero) in the history, or "A
string representing all or part of a URL in the history list.". It is
completely useless here. RTFM, e.g.

<URL:http://ific.uv.es/informatica/manuales/ClientReferenceJS13/history.html#1193970>


PointedEars
 
J

Jean Pierre Daviau

Thomas 'PointedEars' Lahn said:
history.go() expects a number as argument, indicating how far to go back
(less than zero) or forward (greater than zero) in the history, or "A
string representing all or part of a URL in the history list.". It is
completely useless here. RTFM, e.g.

I did not do javascript for some years. I should have remember that.

Thanks
 
J

Jean Pierre Daviau

The followin works, but the viewer has to accept the closing in IExplorer.
It seems inelegant.

<form name="R" onSubmit="var lien='cours1.html?T1=' +
document.R.T1.value;window.open(lien,'','');self.close();">
 
L

Lee

Jean Pierre Daviau said:
I tried theese two ways without success.

function go(inValue){
document.location.replace('cours1.html?T1=' + document.R.T1.value)
}

How are you calling this function?
If it's in the onsubmit handler of your form, consider that you're
telling the browser to perform two conflicting actions:
1. submit the form, and load the resulting content
2. replace the page with your new URL
 
T

Thomas 'PointedEars' Lahn

Jean said:
The followin works, but the viewer has to accept the closing in IExplorer.

And, hopefully, in many other browsers.
It seems inelegant.

It seems to be nonsense.
<form name="R" onSubmit="var lien='cours1.html?T1=' +
document.R.T1.value;window.open(lien,'','');self.close();">

Of course, that is a security measure to prevent loss of history and
browser control due to script kiddies.

If you would explain what you are trying to achieve, one might provide
a suggestion on how to achieve it best. So far, your source code does
not make any sense.


PointedEars
 
R

Randy Webb

Thomas 'PointedEars' Lahn said the following on 11/28/2005 12:10 PM:
Jean Pierre Daviau wrote:

They don't have to accept it, you just have to know how to prevent the
dialog box.

Of course, that is a security measure to prevent loss of history and
browser control due to script kiddies.

And to date, the only browsers that don't allow you to close a window
you didn't open is Mozilla based browsers. IE and Opera allow me to do
it. And I don't think I qualify as a "script kiddie".

And since that feature/bug has been around a lot longer than Mozilla has
it can stop being called a "bug" since even Opera allows it (in some
form or another).
 
J

Jean Pierre Daviau

Lee said:
Jean Pierre Daviau said:


How are you calling this function?
If it's in the onsubmit handler of your form, consider that you're
telling the browser to perform two conflicting actions:
1. submit the form, and load the resulting content
2. replace the page with your new URL
Right.


The following works.


<SCRIPT language="JavaScript">
if(getChip("webJPD", "passez")){
location.replace("cours1.html");
}
function go(inValue){
var lien= 'cours1.html?T1=' + inValue;
document.location.replace(lien);
}
</SCRIPT>
...
<body>
<form name="R">
<fieldset>
<legend>Mot de passe</legend>
<p><input type="text" name="T1" size="20"></p>
<P><INPUT TYPE="button" value="validate"
onClick="go(document.R.T1.value);"></p>
</fieldset>
</form>

'the script kiddy'
 
T

Thomas 'PointedEars' Lahn

Jean said:
The following works.

Not reliably.
<SCRIPT language="JavaScript">

The `type' attribute value is missing for HTML 4, the `language'
attribute is deprecated there.

if(getChip("webJPD", "passez")){
location.replace("cours1.html");
}
function go(inValue){
var lien= 'cours1.html?T1=' + inValue;
document.location.replace(lien);
}

Location objects are host objects, you should test whether they are
supported and whether they provide a replace() method.

<http://www.pointedears.de/scripts/test/whatami>, § 2.

That said, the document.location reference is deprecated long since,
use window.location or location instead.
</SCRIPT>
..
<body>
<form name="R">

This is invalid as well, the `action' attribute value is missing.
<fieldset>
<legend>Mot de passe</legend>
<p><input type="text" name="T1" size="20"></p>
<P><INPUT TYPE="button" value="validate"
onClick="go(document.R.T1.value);"></p>

onclick="go(this.form.elements['T1'].value);"></p>

is standards compliant. Be sure to specify the default scripting language
via a `meta' element in the `head' element in either case. Furthermore,
those are not paragraphs, so using the `p' element in that way is
inappropriate.
</fieldset>
</form>

'the script kiddy'

My comment referred to the abuse of client-side scripting by irresponsible
people (so-called "script kiddies"), especially those who seek to
manipulate the working environment of users, including trying to close
windows not opened with scripting, without their explicit consent. Unless
you use the above source code uncorrected in a public Web document, it
would not qualify as such and hence you would not.


PointedEars
 

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

Similar Threads

document.images 8
meta for two languages 3
document.images[0].X 6
javascript corrupted? 8
circle tracing 10
changing the barckground image 2
running an ex on eMac 8
loading order 2

Members online

Forum statistics

Threads
473,780
Messages
2,569,607
Members
45,240
Latest member
pashute

Latest Threads

Top