Improve company productivity with a Business Account.Sign Up

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 976
  • Last Modified:

oNCLICK - <a href and Vb script

Good Morning Folks

What i want to do is when the user clicks on the link,
<a href="<%=  RootPathNs %>" onclick= "cleanout();return false" target="_top">Log Out and return to Non Secure area "<%=yr_url_ns%>" </a><br>
I want the the function cleanout to run before loading the url.
  So here is the code


in an Asp page called Logout.asp

with other functions that are working
<%

Function cleanout()

     Session("membrid")=""
End Function

Function RootPathNs() 'this one works as I have the values from this in the href below
            ss =Request.ServerVariables("HTTP_REFERER")

            for i=len(ss)-2 to 0      step -1
                  if Mid(ss,i,1) ="/" then
                        len1 = i
                        exit for
                  end if
            next
            path = Mid(ss,1,len1-1)
                lenPath=Len(path)
            lenss=Len(ss)
                yr_url_ns=Right(ss,(lenss-lenPath-3))
            RootPathNs=path&"/"&yr_url_ns

            
End Function
%>


after all the HTML tags etc

<a href="<%=  RootPathNs %>" onclick= "cleanout();return false" target="_top">Log Out and return to Non Secure area "<%=yr_url_ns%>" </a><br>



So I need the following answered -
1. can a vb script be called ? - I have seen examples on the web however they were doing a lot more
2. If the answer to question 1 is Yes
     then fix my code to make it work in all browsers

   Inf the answer is no or may be
then give me a working example of a script that would do the intended

3. If you are answer is right the first time I WILL GET THE ADMINISTRATORS TO GIVE THE FULL 500 POINTS - IF A LOT OF BACK AND FORTH IS INVOLVED THE ONLY 250 POINTS

Not trying to be bad but I am running out of time and of late I have not been getting any complete answers. Yes me and everyone else who is seeking advice comes here because we are stuck so to confuse the confused is easy. I believe a true expert can make the difficult simple as I do in areas where the


Thanks
Su2117
0
su2117
Asked:
su2117
  • 3
  • 3
1 Solution
 
Dave BaldwinFixer of ProblemsCommented:
"onclick= "cleanout();return false""" runs javascript and javascript can't call a server side ASP routine.  You would have to have cleanout(); be an AJAX routine that calls an ASP page that could be as simple as your cleanout routine.  Why do you have "return false"?  That should stop the link from being taken.
0
 
su2117Author Commented:
Hi Dave

Ok so How do I sovle it

Bottom line - need the session variable reset to "" 
then the page http://..../homeindex.htm opened with a target="_top"

What is the easiest / cleanest solution and can give the details

Thanks
Su2117
0
 
Dave BaldwinFixer of ProblemsCommented:
One possiblity is to make a page (logout2.asp) that simply does those two things and then redirects to the desired page.  Then all you need is:

<a href="logout2.asp">Log Out and return to Non Secure area</a>

You could include the "<%=yr_url_ns%>" still if you wanted.
<%

Session("membrid")=""

'Function RootPathNs() 'this one works as I have the values from this in the href below
            ss =Request.ServerVariables("HTTP_REFERER")

            for i=len(ss)-2 to 0      step -1
                  if Mid(ss,i,1) ="/" then
                        len1 = i
                        exit for
                  end if
            next
            path = Mid(ss,1,len1-1)
                lenPath=Len(path)
            lenss=Len(ss)
                yr_url_ns=Right(ss,(lenss-lenPath-3))
            RootPathNs=path&"/"&yr_url_ns
'End Function

Response.Redirect RootPathNs
%>

Open in new window

0
What Kind of Coding Program is Right for You?

There are many ways to learn to code these days. From coding bootcamps like Flatiron School to online courses to totally free beginner resources. The best way to learn to code depends on many factors, but the most important one is you. See what course is best for you.

 
su2117Author Commented:
Hi Dave
took your advice
However when the next page opens the referer info changes
so i added an input hidden in the hope of passing the value to logout2.asp
(All this would not be necessary if the page did not have secure and unsecure area that mirror the flow
So secure s_pagex.htm shows different info while non secure page pagex.htm ) Hence the user would like to log out and land in the corresponding non secure page. Same way at the time of login the user shows up in the secure page equivalent to the non secure page)
code from logout.asp

<td width="50%"> <Div align=left>
<a href="<%= yy %>" target="_top">Go Back "<%=yr_url%>" </a><br>
</td>

<td width="50%"> <Div align=right>

<a href="logout2.asp" target="_top">Log Out and return to Non Secure area "<%=yr_url_ns%>" </a><br>
</td>


also the target "_top " opens in a new tab I thought it was supposed to open in the same page


Thanks
Su2117
 
</tr>
<tr>
<td> <input type="hidden" name=originRootPathNs value="<%=RootPathNs %>">
</td>
</tr>


code from LOGOUT2.ASP
<%

Session("membrid")=""

'
            RootPathNs2=form.originRootPathNs
 
response.write RootPathNs2
Response.Redirect RootPathNs2
%>
0
 
BadotzCommented:

also the target "_top " opens in a new tab I thought it was supposed to open in the same page

should be:

<a href="logout2.asp" target="_self">Log Out and return to Non Secure area "<%=yr_url_ns%>" </a><br>
0
 
su2117Author Commented:
I like the way Dave Baldwin took the time to read my post then answer / pertinently.

Note to Dave please keep your ability to talk to us technically challenged .

Thanks
0
 
Dave BaldwinFixer of ProblemsCommented:
I keep trying.  And good fix for the Referer problem.  Thanks for the points.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Get 10% Off Your First Squarespace Website

Ready to showcase your work, publish content or promote your business online? With Squarespace’s award-winning templates and 24/7 customer service, getting started is simple. Head to Squarespace.com and use offer code ‘EXPERTS’ to get 10% off your first purchase.

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