Forum Moderators: coopster

Message Too Old, No Replies

document.location is not working with FireFox

document.location with named anchor tag is not working with FireFox

         

mindshare

2:56 pm on Apr 29, 2005 (gmt 0)

10+ Year Member



I have the follownig code to test our applications for changing the URL on a web page using document.location. When changing the location, the page should jump to the name tag defined in the page.

The code works great on IE without any problem however in FireFox I get a blank page. I look at the source code and it has all of the code for the page however the page does not get displayed unless I hit the refresh button.

Here is the code. Can someone help me?

<?php
$changeURL = $_POST['changeURL'];
if ($changeURL == 1)
{
echo <<<EOF
<SCRIPT TYPE="text/javascript">
window.location = window.location.href+'#uploadSection';
</SCRIPT>
EOF;
}
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>InterChange: Administrative Upload</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body>
<form name="testAnchor" method="post" action="testAnchor.php" enctype="multipart/form-data">
<input type="hidden" name="changeURL" value=1>
<input type="button" name="Test" value="Test" onClick="submit();return false;">
<input type="checkbox" name="TestCheckBox">
<a name="#uploadSection"></a>
</form>
</body>
</html>

jatar_k

7:17 pm on May 2, 2005 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



strange, and that is all that is on the page?

mcibor

9:00 pm on May 2, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Shouldn't you have <script> tags in head?


<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>InterChange: Administrative Upload</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<?php
$changeURL = $_POST['changeURL'];
if ($changeURL == 1)
{
echo <<<EOF
<SCRIPT TYPE="text/javascript">
window.location = window.location.href+'#uploadSection';
</SCRIPT>
EOF;
}
?>
</head>
<body>
<form name="testAnchor" method="post" action="testAnchor.php" enctype="multipart/form-data">
<input type="hidden" name="changeURL" value=1>
<input type="button" name="Test" value="Test" onClick="submit();return false;">
<input type="checkbox" name="TestCheckBox">
<a name="#uploadSection"></a>
</form>
</body>
</html>

If this doesn't work, then I don't know what will

Michal Cibor

mindshare

1:05 am on May 3, 2005 (gmt 0)

10+ Year Member



I put the code in the head and it still was not working.

I created another JavaScript by the name of
docLoaded. I called the JavaScript on the body tag using the onLoad attribute.

<body onLoad="docLoaded()">

In the docLoaded javascript I have the following code

<?php
$changeURL = $_POST['changeURL'];
if ($changeURL == 1)
{
echo <<<EOF
<SCRIPT TYPE="text/javascript">
window.location = window.location.href+'#uploadSection';
</SCRIPT>
EOF;
}
?>

After the modification, the application works on Mozilla.

I think that Mozilla does not support forward referencing to a name tag. It works fine in IE.

So in Mozilla, the page has to be loaded first and then we can jump to an internal link.