Solved

Moving to next page only if authorised.

Posted on 2002-04-03
13
161 Views
Last Modified: 2011-10-03
Hi experts,
 I need to go to my second page only if i pass through my first page.If users directly go to 2 page they should not be allowed to do so.
I tried with the following code.
But if tells that the object does'nt support such action.
 my coding is as below. please help me out.......

Thanks in advance.
Shanth_77
 
<html>
<head>

<SCRIPT LANGUAGE=JAVASCRIPT TYPE="TEXT/JAVASCRIPT">
<!-- Hide script from old browsers<br>
if(document.referrer ="C:\javascript\objbutton.html")

     location.href = "C:\javascript\SessionTry.html";


//-- Stop hiding script -->
</SCRIPT>  

</head>
<body>
HAI
</body>
</html>
0
Comment
Question by:shanth_77
  • 5
  • 4
  • 2
  • +2
13 Comments
 
LVL 30

Expert Comment

by:third
Comment Utility
it should be,

<html>
<head>

<SCRIPT LANGUAGE=JAVASCRIPT TYPE="TEXT/JAVASCRIPT">
<!-- Hide script from old browsers<br>
if(document.referrer=="C:\javascript\objbutton.html"){
  location.href = "C:\javascript\SessionTry.html";
}
//-- Stop hiding script -->
</SCRIPT>  

</head>
<body>
HAI
</body>
</html>
0
 
LVL 30

Expert Comment

by:third
Comment Utility
take note of,

if (x == y){ //comparing boolean expressions
  //statement here
}
0
 
LVL 30

Expert Comment

by:third
Comment Utility

also, take MORE attention on

Questions Asked 15
Last 10 Grades Given A B A B  
Question Grading Record 4 Answers Graded / 4 Answers Received

you have several aging open questions. if you continue this kind of attitude im very sure that you can never expect help from ME (and perhaps most of the experts). so to avoid this from happening, kindly settle those threads.
0
 

Author Comment

by:shanth_77
Comment Utility
hi third,
 I tried with the above, now there are no errors. but even if i proceed via the objbutton page,it still gives me the alert of going to the home page. I feel the code of document is not reffered at all.I have modified my code a bit. please do have a look.

Thanks in advance.
shanth_77

<html>
<head>

<SCRIPT LANGUAGE=JAVASCRIPT TYPE="TEXT/JAVASCRIPT">
<!-- Hide script from old browsers<br>
if(document.referrer=="C:\ksshanth\jsbishan\objbutton.html")
{
   alert(document.referrer);
   location.href = "C:\ksshanth\jsbishan\SessionTry.html";
}
else
{
alert("please visit home");
}
//-- Stop hiding script -->
</SCRIPT>  

</head>
<body>
HAI
</body>
</html>
0
 

Author Comment

by:shanth_77
Comment Utility
hi third,
  even if i visit the home page, the sessionpage gives me an alert of "visit home".

I have taken note of the grades given.

thanks in advance.

0
 
LVL 30

Expert Comment

by:third
Comment Utility
it's not only the grades given, what im talkin about are the open questions. i have the answer but i can't give you not unless you settle your previous questions.

review the guidelines,

http://www.experts-exchange.com/jsp/cmtyQuestAnswer.jsp
0
IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 

Author Comment

by:shanth_77
Comment Utility
Hi Third,
  I have settled almost most of my questions. Ive got 2 more questions without proper answers, others have been solved. Can u help me out now for the above question ?



0
 
LVL 30

Expert Comment

by:third
Comment Utility
ok, good to hear that! keep it up!

now the answer is here,

The referrer property only works when you use it on a live Web server. If you're designing your page offline, these scripts won't work until you actually post the page to a Web server.

http://www.netmechanic.com/news/vol4/javascript_no14.htm

in other words use,

<SCRIPT LANGUAGE=JAVASCRIPT TYPE="TEXT/JAVASCRIPT">
<!-- Hide script from old browsers<br>
if(document.referrer=="http://ursite/objbutton.html")
{
  alert(document.referrer);
  location.href = "http://ursite/SessionTry.html";
}
else
{
alert("please visit home");
}
//-- Stop hiding script -->
</SCRIPT>  



0
 
LVL 1

Accepted Solution

by:
wolfpackinc earned 50 total points
Comment Utility
Put in header of the page to normally start from:

<SCRIPT LANGUAGE="Javascript">
<!--
self.name = "android"
-->
</SCRIPT>

Put in header of page you don't want accessed directly:

<SCRIPT>

<!--
//specify valid referrals for script to accept
//if you wish an entire domain to be valid, enter that (ie: "javascriptkit.com")
var validreferrals="android"
if (window.opener == null){
alert("You can not access this page directly!\nYou will now be redirected")
window.location.replace("Page1.html")
}
else if(window.opener.name != validreferrals){
alert("You can not access this page directly!\nYou will now be redirected")
window.location.replace("Page1.html")
}
//-->
</SCRIPT>
0
 
LVL 75

Expert Comment

by:Michel Plungjan
Comment Utility
So I right-click, see the name and do a
javascript:window.name="android"; window.location='page2.html'
;-)

Michel
0
 
LVL 19

Expert Comment

by:webwoman
Comment Utility
And when you publish it, this
="C:\javascript\objbutton.html")
will be totally useless. It's a reference to your hard drive, not where the file is on the server.

This really isn't the way to do what you want. If you want to keep people out of the second page, you need to set a cookie on the first one and check for it on the second.

Cookies are NOT the simplest things to write for a beginner. YOu can get lots of various cookie scripts at www.javascriptsource.com
0
 
LVL 1

Expert Comment

by:wolfpackinc
Comment Utility
>>So I right-click, see the name and do a
>>javascript:window.name="android"; >>window.location='page2.html';

True but it depends on what reasons he wants to start with the first page...

For example I have a first page that redirects according to browser etc. user is using and I want them to go to the proper page and not directly to one of them.


>>If you want to keep people out of the second page, you
need to set a cookie on the first one and check for it on the second.

This sounds like a good idea

0
 

Author Comment

by:shanth_77
Comment Utility
hi ,
 I works well. But i was slightly confused of how window.opener works because, in my case its always null.
Please explain ur coding for my clarity.
Thanks a lot.
Shanth_77

0

Featured Post

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

In my daily work (mainly using ASP.net), I need to write a lot of JavaScript code. One of the most repetitive tasks I do are the jQuery Ajax calls. You know: (CODE) I don't know if for you it's the same, but for me is soooo tedious to write the …
Article by: DanRollins
This article describes a JavaScript program that creates a maze made of hexagonal cells.  In Part 2 (http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/A_7850-Hex-Maze-Part-2.html), we'll extend the program by adding a depth-…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

763 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

7 Experts available now in Live!

Get 1:1 Help Now