Click to See Complete Forum and Search --> : Document location href problem


rbeech23
01-01-2003, 10:37 AM
Here's a js function:
function somefunction( MembershipLevel ) {

if (MembershipLevel == 1) {
var wc=window.confirm("Messages can only be read by Gold members. Click OK to upgrade to Gold status");
if (wc == true) {
document.location.href='MembersArea.jsp';
}
}

When Ok is clicked on the confirm window, the page doesn't proceed to MembersArea.jsp. I've tested the condition which is passing MembershipLevel okay, wc returns true and if(wc==true) is entered but document.location.href... does not perform the command.
I've run this elsewhere slightly differently which works okay.

Why doesn't document.location.href="MembersArea.jsp" work ???

Any help appreciated.

Thanks

rbeech23
01-01-2003, 11:59 AM
Thanks
I've tried it exactly as you've suggested but am getting the same response ie nothing.

Is there anything else I should be looking at.

The html code is auto generated in a jsp page from a java bean.

Part of the html is simply an onclick which calls the above function.

Any other suggestions ?

Regards

rbeech23
01-01-2003, 02:22 PM
I've tried as you suggest with no ifs and there's no change.

I've also tried it in a separate page, a bit of simple html as follows:

<td><a name='Read'></a><a href=# onClick='JavaScript:document.location.href="MembersArea.jsp";'><br><p>
Read Message</a><br>
<br><br><hr></td>

And that doesn't react either.

I'm puzzled, if you've any other suggestions I'll be grateful

Thanks
Rob

rbeech23
01-01-2003, 06:33 PM
Can you try this then:

Html code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">

<script language="JavaScript1.1" src="scripts/test.js" ></script>

<html>
<head>
<title>Meet on holiday - Welcome</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">

<link rel="stylesheet" href="styles.css" type="text/css">
</head>
<body bgcolor="#9966cc" text="#000000" leftmargin="0" topmargin="0" >
<td><a name='1000001'></a><a href=# onClick='newPage()'><br><p>
Read Message</a><br>
<br><br><hr></td>
</body>
</html>

Javascript including function:
function newPage() {

self.location.href='newpage.htm';
}

I still get no response with this, can you let me know what you get, I'd expect an error saying newpage.htm doesn't exist but I'd be happy with that.

Thanks again
Rob

rbeech23
01-02-2003, 04:01 AM
Cheers Dave, that simple addition works !!

Much appreciated.

Regards
Rob