?
Solved

Breaking out of a Frame VBScript - onload logout when cookie expires

Posted on 2003-03-12
8
Medium Priority
?
1,012 Views
Last Modified: 2008-03-03
I have a page (2.asp) that loads within the "Mainframe" of an existing page (frames.asp). When 2.asp loads, I want this page to check if the permission in cookie is set for the page to load. If found false, it should break out of the frame and load logout.asp

The cookie was first set on the loginnow.asp with this code.
<%response.buffer=true
response.cookies("module").Expires=date + 1
response.cookies("module")("permission")= "yes" %>

On 2.asp the onload() function body checks if the permission is still "yes"

<script type="text/vbscript">
function onload()
 permission1=request.cookies("module")("permission")
  if permission1 = "" or permission2="no" then
    javas()
  end if
end function
</script>

javas() is a javascript which is

<script type="text/javascript">
function javas()
{
  if (window.top != window.self)
   {
    window.top.location="logout.asp"
   }
}
</script>

Unfortunately, this doesnt work! Is there a way to break out of a frame in VBScript. Also the error is on Request.cookies !!

Is there is something wrong in my code? I would appreciate if you can help me out with this.
0
Comment
Question by:sciber_dude
[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
  • 5
  • 3
8 Comments
 
LVL 1

Expert Comment

by:herongan
ID: 8124479
You try following code:

=============================================
<%response.buffer=true
response.cookies("module").Expires=date + 1
response.cookies("module")("permission")= "no"
%>

<html>

<script language="vbscript">
function window_onLoad()
permission1="<%=request.cookies("module")("permission")%>"
 if permission1 = "" or permission1="no" then
   javas()
 end if
end function
</script>

<script language="javascript">
function javas()
{
   top.window.location="logout.asp"
}
</script>

<body>
</body>
</html>

=============================================
0
 
LVL 1

Expert Comment

by:herongan
ID: 8124512
If you want to check the current window is the top or not, you can use following code.

if (self!=top) // self isn't the top
{
  top.window.location="logout.asp"
}

But i don't know why you need to check it?

Hope can help!
0
 
LVL 1

Expert Comment

by:herongan
ID: 8124552
"request" is a server-side object.
Your VBScript is a client-side script.
For this reason, the error will occur when you trying to get a cookie via "request.cookies".
0
Industry Leaders: 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!

 
LVL 11

Author Comment

by:sciber_dude
ID: 8124767
Herogan,
Thank you for your replies. It did help me find the solution. "request" is a server-side object. This was cause of the problem.

I have found the solution to my problem:-

1. I've included the following line to 2.asp before <HTML> tag
<!--#include file="checkpermission.asp"-->

2. I have created a new page called checkpermission.asp and have written the following code
<%
response.buffer=true
permission1=request.cookies("module")("permission")

if permission1 = "" or permission1 = "no" then
 Response.Redirect "logout.asp"
end if
%>

3. On the logout.asp page, I have added the following Javascript which has an 'onload' function. This breaks this page out of the frames.
<script type="text/javascript">
function javas()
{
 if (window.top != window.self)
  {
   window.top.location="logout.asp"
  }
}
</script>

The advantage of this technique is that I dont have to write 'permission checking' code on all the pages in the module. Adding just the #include line will do the job.

This is the first time I have asked a question on this forum. Even though your answer has not given me the exact solution to my question, I should give you credit for showing me the right direction.

Thanks.
0
 
LVL 11

Author Comment

by:sciber_dude
ID: 8124777
How do I award the points / grade?
0
 
LVL 1

Accepted Solution

by:
herongan earned 345 total points
ID: 8124828
After you answer the question, if the answer can help someone to solve the problem. He/She will click "Accept Comment As Answer"(Can you see this word on my posted message?). Then you will gain a expert point.

Hence, pls click the "Accept Comment As Answer" to give me a expert point.HaHa =)

Hero
0
 
LVL 1

Expert Comment

by:herongan
ID: 8124852
Besides it, the "Available Question Points" will auto increase 5 points for each day.
Or you can spend $$ to buy.
0
 
LVL 11

Author Comment

by:sciber_dude
ID: 8131466
Thank you for you help!
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Hello, all! I just recently started using Microsoft's IIS 7.5 within Windows 7, as I just downloaded and installed the 90 day trial of Windows 7. (Got to love Microsoft for allowing 90 days) The main reason for downloading and testing Windows 7 is t…
I would like to start this tip/trick by saying Thank You, to all who said that this could not be done, as it forced me to make sure that it could be accomplished. :) To start, I want to make sure everyone understands the importance of utilizing p…
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…

764 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