Javascript function is not working

VERIFIED INVALID

Status

()

VERIFIED INVALID
16 years ago
14 years ago

People

(Reporter: creativetim, Assigned: rogerl)

Tracking

Trunk
x86
Windows XP
Points:
---

Firefox Tracking Flags

(Not tracked)

Details

(Reporter)

Description

16 years ago
User-Agent:       Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.4a) Gecko/20030401
Build Identifier: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.4a) Gecko/20030401

I'd give you the URL, but it's an administration section on a site I'm
developing and can't do that.  But basically I have a form button that when
clicked, calls a javascript function in the header of the page.  The javascript
function takes a few parameters and then just forwards the user to the URL. 
This is an example of the function:

	function editSong(song, artist, band){
document.location.href("index.cfm?f=editS4&song="+song+"&artist="+artist+"&band="+band);
	}

It's a simple JavaScript function that works in IE, but not in Mozilla.

Reproducible: Always

Steps to Reproduce:
1.Click the button
2.Watch nothing happen.
3.Report bug to you.

Actual Results:  
Nothing happened, and I'm here reporting it to you.

Expected Results:  
It should have forward the user to the url I specified in the function, just
like IE does.

I have tried using <script language="JavaScript|JavaScript1.1|JavaScript1.2">
and nothing works. :/
>document.location.href("index.cfm?f=editS4&song="+song+"&artist="+artist+"&band="+band);

document.location.href is a String object.  Which means that you can't call it
as a function.  But you _can_ assign to it...

IE has this weird violation of the JavaScript language semantics where the same
identifier can refer to both a function object and to some other random object
and IE tries to guess which one you mean.... but that's a bug in IE.
Status: UNCONFIRMED → RESOLVED
Last Resolved: 16 years ago
Resolution: --- → INVALID

Comment 2

16 years ago
Marking Verified. Here is a sample script that does work in IE:

<script>
document.location.href("http://www.mozilla.org");
</script>


In Mozilla, it produces an error in the JavaScript Console:
Error: document.location.href is not a function


Here is the way it should be coded to work in all browsers:

<script>
document.location.href = "http://www.mozilla.org";
</script>
Status: RESOLVED → VERIFIED
*** Bug 306237 has been marked as a duplicate of this bug. ***
You need to log in before you can comment on or make changes to this bug.