469,654 Members | 1,850 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,654 developers. It's quick & easy.

What is the right IE version for command location.href?

Hi

I have a problem using the location.href("ProductL.htm") javascript
code. Using this code on my system ( W98 SE, IE 6.0) is working
correctly.
But if a user has W2000 IE 5.0 it doesn't work. When using this code
the browser shows an error on page in the statusbar. If I click on the
statusbar to find out what is causing the error I see this description
'The property of this method is not supported by this object' ( I have
translated this in English, my IE browser is in dutch)

Does the location.href only work for a certain version of IE?

Regards

Jul 23 '05 #1
13 2003

Jerry Manner wrote:
I have a problem using the location.href("ProductL.htm") javascript
code.


Try to assign to the property e.g.
location.href = "ProductL.htm"
your code looks like a function call.

--

Martin Honnen
http://JavaScript.FAQTs.com/
Jul 23 '05 #2
Hi

I have tried what you said, but that gave me the same result. Is
location.href only working for a certain version of IE?

Jul 23 '05 #3
Lee
Jerry Manner said:

Hi

I have tried what you said, but that gave me the same result. Is
location.href only working for a certain version of IE?


No, it works in all versions. Post *exactly* what you are trying.

Jul 23 '05 #4
Hi

Here is the original code which is working for my system ( W98 SE, IE
6) but not for another person ( W2000, IE 5).

function CheckLogin() {

var textField = document.getElementById("T1");

if (textField.value == 'Marjolein Visser')
{
location.href("IntranetP.htm");
}
else if (textField.value == 'Hans Veerkamp')
{
location.href("IntranetELP.htm");
}
else if (textField.value == 'Steven Badle')
{
location.href("IntranetSBadleP .htm");
}
}

This function is alled from an onclick event of a image.

Jul 23 '05 #5


Jerry Manner wrote:

Here is the original code which is working for my system ( W98 SE, IE
6) but not for another person ( W2000, IE 5).
What happens there, any error messages?

function CheckLogin() {

var textField = document.getElementById("T1");

if (textField.value == 'Marjolein Visser')
{
location.href("IntranetP.htm");
As said it should be an assignment
location.href = "IntranetP.htm"
at least if you want to write cross browser code for the web, the
function call might work with an IE/Win only intranet.

location.href("IntranetSBadleP .htm");


You need to escape the space character
"IntranetSBadleP%20.htm"
in a URL, that is the only thing that I see that might cause problems.

--

Martin Honnen
http://JavaScript.FAQTs.com/
Jul 23 '05 #6
Hi

The sapce was an error in the posting. In the code there is no space. I
did change the location.href("IntranetP.htm")*; into location.href =
"IntranetP.htm", but that resulted in the same error ''The property of
this method is not supported by this object'

Jul 23 '05 #7


Jerry Manner wrote:

The sapce was an error in the posting. In the code there is no space. I
did change the location.href("IntranetP.htm")*; into location.href =
"IntranetP.htm", but that resulted in the same error ''The property of
this method is not supported by this object'


I am not sure what could be causing this and therefore have to keep
suggesting other attempts as a guess work, you could try whether
directly assigning
location = "IntranetP.htm";
solves that problem. The location object is a bit magical in allowing an
assignment to itself when you want to set the href property.
--

Martin Honnen
http://JavaScript.FAQTs.com/
Jul 23 '05 #8
Jerry Manner wrote:
Hi

I have a problem using the location.href("ProductL.htm") javascript
code. Using this code on my system ( W98 SE, IE 6.0) is working
correctly.
But if a user has W2000 IE 5.0 it doesn't work. When using this code
the browser shows an error on page in the statusbar. If I click on the
statusbar to find out what is causing the error I see this description
'The property of this method is not supported by this object' ( I have
translated this in English, my IE browser is in dutch)

Does the location.href only work for a certain version of IE?

Regards


"Object doesn't support this property or method" is the error we'd see
in English browsers. Essentially, the location object (if it exists)
doesn't have a member named href.

Since all versions of IE since and including at least 4.0 support the
location object and the href member of it, this suggests to me that the
location object you're working with is not what we might expect it to
be. For instance, if your function is being called as a member of an
object that also has a location member, then the unqualified reference
to location will refer to the object's location member and not the
window's location.

If assigning to the location object doesn't work, try fully-qualifying
it as window.location.href

window.location.href = 'File.html';

Jul 23 '05 #9
Christopher J. Hahn wrote:
<snip>
Since all versions of IE since and including at least 4.0
support the location object and the href member of it,
this suggests to me that the location object you're working
with is not what we might expect it to be. For instance, if
your function is being called as a member of an object that
also has a location member, then the unqualified reference
to location will refer to the object's location member and
not the window's location.


Unqualified identifiers are resolved against the function's scope chain
so even if the function was called as a method of an object with a -
location - property the unqualified identifier would not be resolved as
a reference to that object property, unless that object had been added
to the function's scope chain explicitly.

Explicitly adding a custom JS object to the scope chain of a function
requires that the function be created in a - with - statement, which is
only possible with function expressions. The OP's posted code is not a
function expression, but might just about be an inner function
declaration inside a function expression. Though that is extremely
unlikely (and it would be another serious omission on the OP's part not
to have included the outer function(s) with the code).

Richard.
Jul 23 '05 #10
<Since all versions of IE since and including at least 4.0 support the
<location object and the href member of it, this suggests to me that
the
<location object you're working with is not what we might expect it to
<be. For instance, if your function is being called as a member of an
<object that also has a location member, then the unqualified reference

<to location will refer to the object's location member and not the
<window's location.

Hi

I call my JS function in an onclick event of an image like this
onclick="CheckLogin()". Further, if I look at the entire html code on
the page I see that the location member is only used in the JS function
I placed in my original posting

Jul 23 '05 #11
Richard Cornford wrote:
Christopher J. Hahn wrote:
<snip>
Since all versions of IE since and including at least 4.0
support the location object and the href member of it,
this suggests to me that the location object you're working
with is not what we might expect it to be. For instance, if
your function is being called as a member of an object that
also has a location member, then the unqualified reference
to location will refer to the object's location member and
not the window's location.


Unqualified identifiers are resolved against the function's scope chain
so even if the function was called as a method of an object with a -
location - property the unqualified identifier would not be resolved as
a reference to that object property, unless that object had been added
to the function's scope chain explicitly.

[snip]

Of course you're right. The example I cited was flawed and wouldn't
apply in this case.

I think it still stands that, given the error message, the 'location'
object being worked with probably is not the window.location we would
expect it to be. There is too little information to say exactly why
that would be in this case.

Ah well. Was hoping to contribute in some way to an unresolved question.

Jul 23 '05 #12
Jerry Manner wrote:
<Since all versions of IE since and including at least 4.0 support the
<location object and the href member of it, this suggests to me that
the
<location object you're working with is not what we might expect it to
<be. For instance, if your function is being called as a member of an
<object that also has a location member, then the unqualified reference

<to location will refer to the object's location member and not the
<window's location.

Hi

I call my JS function in an onclick event of an image like this
onclick="CheckLogin()". Further, if I look at the entire html code on
the page I see that the location member is only used in the JS function
I placed in my original posting


What happens if you use
window.location.href = 'someFile.html';
instead?

Jul 23 '05 #13
Hi

it is working now. If I use location.href = "somefile.htm" it sends the
user to that page. I don't know why it did not worked the first time I
used the same code. But it is working now.

Thank you all for your help!!!!

Jul 23 '05 #14

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

14 posts views Thread by Frances Del Rio | last post: by
3 posts views Thread by Jim Cobban | last post: by
121 posts views Thread by typingcat | last post: by
26 posts views Thread by Lasse Edsvik | last post: by
8 posts views Thread by Thaqalainnaqvi | last post: by
3 posts views Thread by stephen.cunliffe | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.