• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1905
  • Last Modified:

Javascript go to next page...using HREF

I have a page where i want to hide the actual href link. when they click on the link (which is an image) i want the window/screen to move/go to another screen, but it's not working, the function is running but the pages doesn't change ... here is my code:

<%@ Language=VBScript %>
<HTML>
<HEAD>
<SCRIPT ID=clientEventHandlersJS LANGUAGE=javascript>
<!--
function gotonextpage(info) {
     nextscreenloc = ""
     var srtlocation = window.document.location.href;
     patharray = srtlocation.split("/")
     for (i = 0; i < (patharray.length-1); i++) {
         if (i > 0) nextscreenloc += "/"
         nextscreenloc += patharray[i]
     }
     nextscreenloc += "/wk7.asp"
     window.location.href = nextscreenloc;
}
//-->
</SCRIPT>
<META HTTP-EQUIV="Pragma" CONTENT="No-cache">
<META http-equiv="expires" content="-1">
</HEAD>
<BODY>
<a href="#" onclick="gotonextpage();"><img border="0" src="../images/viewandprint.jpg" ></a>
</BODY>
</HTML>
0
tomhoran
Asked:
tomhoran
  • 5
  • 5
1 Solution
 
jonnalCommented:
hi
something like this ?


<HTML>
<HEAD>
<SCRIPT ID=clientEventHandlersJS LANGUAGE=javascript>
<!--
function gotonextpage(info) {
    var nextscreenloc = "http://www.yoururl.com/dir1/dir2/etc/wk"
    window.location = nextscreenloc+info+'.asp';
}
//-->
</SCRIPT>
<META HTTP-EQUIV="Pragma" CONTENT="No-cache">
<META http-equiv="expires" content="-1">
</HEAD>
<BODY>
<a href="#" onclick="gotonextpage(7);"><img border="0" src="../images/viewandprint.jpg" ></a>
</BODY>
</HTML>
0
 
tomhoranAuthor Commented:
my code works to create a valid location string, it just doesn;t go to the next screen. i changed it from:

window.location.href = nextscreenloc;

to:

window.location = nextscreenloc;

based on your suggestion, but it still doesn't work??

0
 
jonnalCommented:
hi
return false missing eg

<a href="#" onclick="gotonextpage();return false">

0
The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

 
tomhoranAuthor Commented:
you got it...thanks!!
0
 
tomhoranAuthor Commented:
jonnal

one more quick question can i access passed parms from the first window. i'm using ASP so normally i would use:

testcheck = Request.QueryString("testcheck") to get the testcheck parm that was passed.

i need to pass this parm onto the next page to, so when i set the new location i need to pass the testcheck parm along. Thanks
0
 
jonnalCommented:
hi again
you can use a query string
page below calls itself
and set the combo to the value in the query string when link is pressed

<head>
<title></title>
<script language="JavaScript">
<!--
var srcc="";

function getsrc(){
if(location.search != ""){
var stri = location.search.substring(1,location.search.length)
document.frm.TEMP.selectedIndex = parseInt(stri);
}
}

function setsrc(){
location = 'query.htm?'+srcc;
}

//  -->
</script>
</head>
<body body onload="getsrc()">

<form name="frm">
<select NAME="TEMP" onChange="srcc=this.selectedIndex">
<option value></option>
<option value="AAAAAA">AAAAAA</option>
<option value="BBBBBB">BBBBBB</option>
<option value="CCCCCC">CCCCCC</option>
<option value="DDDDDD">DDDDDD</option>
<option value="EEEEEE">EEEEEE</option>
</select>
</form>
<a href="query.htm" onclick="setsrc();return false">next</a>
</body>
</html>
0
 
tomhoranAuthor Commented:
thanks, not sure my question was straiget forward enough.

if i have a href like this on checkprint1.asp:

href=./checkprint2.asp?plainpaper=N

which creates a link on checkprint1.asp. When someone click on this link the window/screen will move from checkprint1.asp to window/screen checkprint2.asp.

what i want to know is when i am running the gotonextpage function (in checkprint2.asp) how can i figure out what value was passed in the  "plainpaper" parm. I know how to create hidden controls in a form (and how to acces the hidden control using javascript), but i don't want a form of the checkprint2.asp screen/window. What i need to know is how to get the "plainpaper" parm value.

thanks.
0
 
jonnalCommented:
hi

href=./checkprint2.asp?plainpaper=N&pram2=yes&pram3=no

function getsrc(){
if(location.search != ""){
var stri = location.search.substring(1,location.search.length)
prams = stri.split('&')
for(i=0;i<prams.length;i++){
eval(prams[i]);
}
}
}

should make page variables
plainpaper with value = N
pram2 = "yes"
pram3 = "no"

and to send those vars to the new page just string build a query string


jonnal

0
 
tomhoranAuthor Commented:
Thank you thank you!!
0
 
jonnalCommented:
cool
0

Featured Post

The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

  • 5
  • 5
Tackle projects and never again get stuck behind a technical roadblock.
Join Now