Solved

oNCLICK - <a href  and Vb script

Posted on 2011-03-11
7
926 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 82

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 82

Accepted Solution

by:
Dave Baldwin earned 300 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
Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

 

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 82

Expert Comment

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

Featured Post

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Need help editing script 3 54
Website Home page blank 4 27
Modify Table Width 6 15
ASP Button to clear text 4 20
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 demonstrates how to create a simple responsive confirmation dialog with Ok and Cancel buttons using HTML, CSS, jQuery and Promises
In this tutorial viewers will learn how to position overlapping items using z-index in CSS. They will also learn the restrictions on the z-index property.  Create a new HTML document with an internal stylesheet.: Create a div in CSS and name it Red.…
In this tutorial viewers will learn how to embed videos in a webpage using HTML5. Ensure your DOCTYPE declaration is set to HTML5: "<!DOCTYPE html>": Use the <video> tag to insert a video. Define the src as the URL of your video; this is similar to …

743 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now