Solved

oNCLICK - <a href  and Vb script

Posted on 2011-03-11
7
953 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 3
7 Comments
 
LVL 83

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 83

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
SharePoint Admin?

Enable Your Employees To Focus On The Core With Intuitive Onscreen Guidance That is With You At The Moment of Need.

 

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 83

Expert Comment

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

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

This article discusses how to create an extensible mechanism for linked drop downs.
This article demonstrates how to create a simple responsive confirmation dialog with Ok and Cancel buttons using HTML, CSS, jQuery and Promises
In this Micro Tutorial viewers will learn how to create navigation buttons that change on rollover, using CSS (Continuation of the CSS Image Sprite tutorial) Create a parent ID for all the list items       - Specify position: absolute and display: block…
HTML5 has deprecated a few of the older ways of showing media as well as offering up a new way to create games and animations. Audio, video, and canvas are just a few of the adjustments made between XHTML and HTML5. As we learned in our last micr…

734 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