473,385 Members | 1,919 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

location.replace in a function

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
Nov 27 '05 #1
9 6621
Jean Pierre Daviau said the following on 11/27/2005 3:01 PM:
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";
document.location.replace(lien)

<URL:
http://msdn.microsoft.com/library/de...ds/replace.asp


--
Randy
comp.lang.javascript FAQ - http://jibbering.com/faq & newsgroup weekly
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
Nov 27 '05 #2
"Randy Webb" <Hi************@aol.com> a écrit dans le message de news:
fp********************@comcast.com...
Jean Pierre Daviau said the following on 11/27/2005 3:01 PM:
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";
there is a mistake here
document.location.replace(lien)

<URL:
http://msdn.microsoft.com/library/de...ds/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);">
Nov 28 '05 #3
Jean Pierre Daviau wrote:
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
Nov 28 '05 #4

"Thomas 'PointedEars' Lahn" <Po*********@web.de> a écrit dans le message de
news: 70****************@PointedEars.de...
Jean Pierre Daviau wrote:
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.


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

Thanks
Nov 28 '05 #5
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.c lose();">
Nov 28 '05 #6
Jean Pierre Daviau wrote:
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.c lose();">


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
Nov 28 '05 #7
Thomas 'PointedEars' Lahn said the following on 11/28/2005 12:10 PM:
Jean Pierre Daviau wrote:

The followin works, but the viewer has to accept the closing in IExplorer.
They don't have to accept it, you just have to know how to prevent the
dialog box.

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


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

--
Randy
comp.lang.javascript FAQ - http://jibbering.com/faq & newsgroup weekly
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
Nov 28 '05 #8

"Lee" <RE**************@cox.net> a écrit dans le message de news:
dm*********@drn.newsguy.com...
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

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'
Nov 28 '05 #9
Jean Pierre Daviau wrote:
The following works.
Not reliably.
<SCRIPT language="JavaScript">
The `type' attribute value is missing for HTML 4, the `language'
attribute is deprecated there.

<URL:http://validator.w3.org/>
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
Nov 29 '05 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Andoni | last post by:
Hi, I am only writing for IE 5.5+ so no need for compatibility at all ;-) I am trying to get my users to logoff which they finish on a particular page. This is no problem (or should be no...
2
by: James Marshall | last post by:
I'm trying to override location.replace() but I can't. I can override window.open(), document.write(), and other built-in methods, but not location.replace(). Here's a demo that overrides two...
1
by: David T. Smith | last post by:
I've been working with a page that should act as a 'jump page' before loading a PDF and when I use the location.replace function to replace the jump page with the resulting PDF, both the jump page...
2
by: brian | last post by:
Is there a way to use location.replace in code behind? The code below will work for a window.alert but not for location.replace. For example: Private Sub Page_Load(ByVal sender As...
5
by: spam_me_ not | last post by:
I already understand that one cannot disable a browser's forward and back functions. This is a situation where I have code working in Mozilla V1.6 and would like something similar for Opera and...
10
by: Roland | last post by:
Hello, the example code is the following(the number in parentheses at the beginning are just for reference)(The complete HTML file is at the end of this article): (1)window.location =...
2
by: JHB | last post by:
Hi, How can I do a location.replace when I use a form, like when I use a href? This works. <a href="Ny HTML-side20.htm"; method="post" id="frm" name="BrugerHovedSide"...
18
by: Simula | last post by:
I am developing an HTML javascript application and I want to preserve state in a way that can be book-marked. I chose HTML anchors as a means of preserving state. When the application changes...
13
by: John Smith | last post by:
I am using IE 6.0 from http://www.javaworld.com/javaworld/jw-07-1996/jw-07-javascript-p2.html I gather that "If you need to test a number of command lines, you can reduce the keystrokes by...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.