Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

oNCLICK - <a href  and Vb script

Posted on 2011-03-11
7
Medium Priority
?
973 Views
Last Modified: 2012-05-11
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
Comment
Question by:su2117
  • 3
  • 3
7 Comments
 
LVL 84

Expert Comment

by:Dave Baldwin
ID: 35114550
"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
 

Author Comment

by:su2117
ID: 35114846
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
 
LVL 84

Accepted Solution

by:
Dave Baldwin earned 1200 total points
ID: 35114960
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
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 

Author Comment

by:su2117
ID: 35115518
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
 
LVL 29

Expert Comment

by:Badotz
ID: 35116004

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
 

Author Closing Comment

by:su2117
ID: 35116162
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
 
LVL 84

Expert Comment

by:Dave Baldwin
ID: 35116405
I keep trying.  And good fix for the Referer problem.  Thanks for the points.
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Building a website can seem like a daunting task to the uninitiated but it really only requires knowledge of two basic languages: HTML and CSS.
This article explains how to prepare an HTML email signature template file containing dynamic placeholders for users' Azure AD data. Furthermore, it explains how to use this file to remotely set up a department-wide email signature policy in Office …
In this tutorial viewers will learn how add a scalable full-width header using CSS3. Create a new HTML document with an internal stylesheet. Set a tiled background.:  Create a new div and name it Header. Position it with position:absolute at the top…
In this tutorial viewers will learn how to embed Flash content in a webpage using HTML5. Ensure your DOCTYPE declaration is set to HTML5: "<!DOCTYPE html>": Use the <object> tag to embed Flash content.: To specify that the object is Flash content, d…

972 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question