Saturday, 31 August 2013

Approved method to navigate between pages on same website

Approved method to navigate between pages on same website

I have researched many places to find an answer to this question, but they
never quite answer my real question: What is the best/approved way to move
to a new page within the same website? I have read that it is bad to use
window.location because search engines will think you are hiding
something. But, when I don't want to open a new window (window.open), then
I don't know how else to do it. I use href anchors in links and form
actions, where appropriate. But when I have menus or buttons with onclick,
then I need something else.
Here's an snippet of my code:
my javascript: (with one option commented)
function gotoCat() {
var catcdF = document.catSelect.catcd.value;
<?php
echo
"window.location.href='http://www.mysite.org".$pgmdir."services/busMenu.php?catF='+catcdF;
";
/*
echo
"window.open('http://www.mysite.org".$pgmdir."services/busMenu.php?catF='+catcdF,'','resizable=1,scrollbars=1,toolbar=1,top=50,left=300,width=950,height=800,location=0');
";
*/
?>
}
My dynamic SELECT list in a form (within PHP):
echo " <select name='catcd' id='catcd' size='8' onclick=gotoCat() > \n";
// display list of categories
if ($numcats == 0) { // print message text only
echo "<option value='0' >".$catMsg."</option> \n";
}
else {
for ($i=1; $i<=$numcats; $i++) {
$catcd_db = $catAry[$i][1];
$catName_db = $catAry[$i][2];
echo "<option value='".$catcd_db."'> ".$catName_db." </option> \n";
}
}
echo "</select>";
So, as you can see, I just want a method to allow the user a choice and
then automatically go to the correct web page once selected. This is not
always in a select list. Often it's when they want to exit or get an
error:
if (mysqli_connect_errno()) {
echo "<br/> <p style='text-align:center;'> <button type='button'
class='buttonStyle' style='padding: 4px 20px;' value='Exit' ";
echo
"onClick=\"window.location.href='http://www.mysite.org/services/catSelbus.php?rc=1&func=Rev'\"
> ";
echo "Exit </button></p> ";
}
I cannot use "go back" because they need to go to a prior page, not the
form they came from.
So, unless my navigation methods are really off-the-mark, I guess I need
to know the acceptable method for using javascript onClick to move to the
next page in the same website. Is window.location okay, or should I use
something else?
Any opinions or suggestions are welcome!

No comments:

Post a Comment