PDA

View Full Version : page open chcecker


twilight
06-27-2002, 12:33 PM
hi,
i would like to refer to this thread http://www.codingforums.com/showthread.php?s=&threadid=470
i modified the cool code by ACJavascript a bit. here's how it looks now:

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1250">
<title></title>
</head>

<body>
<script language="javascript">

function go(){
var lg=window.open("page1.htm","GoPage")
document.forms[0].goTrue.value="true"
}
function check(){

if(document.forms[0].goTrue.value=="true"){
self.location="index.htm"
}else{
alert("Please click 'GO Here' first.")
}
}

</script>

<a href="javascript:go()">GO Here</a>

<form>
<input type="hidden" name="goTrue">
</form>

<a href="javascript:check()">Click here</a>
</body>
</html>

the thing i want is for the check() function to check if the visitor is on page2.htm in the GoPage window (he would have to click on page1.htm which is opened by the go() function). is it possible to at all (i assume the script above will need a grand remake)

ACJavascript
06-27-2002, 09:25 PM
Thanks for calling my script cool:D hehe,

I really don't understand what your trying to say.

You want the check() function to check if the user is on page2.html when he clicked the go() function.

or

You want the check() function to check if the user is on the mainpage but is on page2.html when he clicks - Click here.


Sorry, i just don't quite understand :p

twilight
06-27-2002, 09:45 PM
well i want the user to click on a link on page1.htm that will move him to page2.htm. so the basic thing that i want the script to do is to check if the user clicked on page1.htm and moved to page2.htm - i will change the window attributes so that there is no address bar and thanks to it the script (the check() function)would only have to chceck if the 'GoPage' window is opened and the address is different than page1.htm (or if it is easier to write if may check if the page2.htm is loaded within the 'GoPage' window).

hope i made myself clearER now.

cheers
mike

ACJavascript
06-28-2002, 01:25 AM
Okay i think this might just do it. hehehe

This part is the page that opens page1 and page2.

----------

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1250">
<title></title>
</head>

<body>
<script language="javascript">

function go(){
var lg=window.open("page1.html","GoPage")
document.forms[0].goTrue.value="true"
}
function check(){

if(document.forms[0].goTrue.value=="true" && document.forms[0].goTrue2.value=="true"){
self.location="index.htm"
}else{
alert("Please click 'GO Here' first.")
}
}

</script>

<a href="javascript:go()">GO Here</a>

<form>
<input type="hidden" name="goTrue">
<input type="hidden" name="goTrue2">
</form>

<a href="javascript:check()">Click here</a>
</body>
</html>
----------------------


Now put this in on page1 in the head

---------------------
<script language="javascript">

function go(){

window.opener.document.forms[0].goTrue2.value="true"
location.href="page2.html"
}
</script>
-----------------------

Put this in the body for the link to page2

-----------------

<a href="javascript:go()">Click Here</a>

-----------------

What happens is this.

when you click on - Go Here -
it puts true to the goTrue hidden textbox(as we all know)
it then opens page1.
When you click on the page1 link it writes to goTrue2 and opens into page2. Now If you were to go back to the main page, and tried to click the click here link it wouldn't work unless you've gone through the page1 & page2.

I hope this works for ya

glenngv
06-28-2002, 06:29 AM
simplest version:

var lg = null;
function go(){
lg=window.open("page1.htm","GoPage")
}
function check(){

if (lg && !lg.closed && lg.location.href.indexOf("/page2.htm")!=-1){
location.href="index.htm";
}else{
alert("Please click 'GO Here' first.");
}
}

</script>
</head>
<body>
<a href="javascript:go()">GO Here</a>
<a href="javascript:check()">Click here</a>
</body>
</html>

twilight
06-28-2002, 03:51 PM
ok i love you people;) this is the best forum out there!!!

ACJavascript your code is still cool, but today i have a problem based on what glenngv wrote above (his script is also cool and shorter:)).

the script doesn't work when the addresses are full (i mean page1 & 2 are located on different servers than the main file with the script - don't ask:( i just had to do it like that: http://www.republika.pl/~twilight218/page1.htm and http://strony.wp.pl/wp/twilight218/page2.htm [at the moment the links are empty but they're gonna look like that] )

when i replace page1.htm and/or page2.htm with the full addresses something goes wrong and i get a message 'error on page' whuch say 'you're not entitled/no entitlement' (don't know how to translate it exactly, but this way or the other it just doesn't work)

maybe you guys could do something about this (i hope & i believe:D )

ACJavascript
06-28-2002, 06:15 PM
as i'm reading this now, i'm stumped. hehehe

If i come up with anything i post it. I hope Glen though has something up his/her sleeve

twilight
06-28-2002, 08:03 PM
i'm repeating myself now (and i'm not an expert in js), but i think that maybe it will be easier if the script (the check() function)would only have to check if the 'GoPage' window is opened and the address is different than http://www.republika.pl/~twilight218/page1.htm

maybe now somebody could help (of course if there is anybody out there capable of rewriting the glenngv code so that it works with full addresses i would appreciate it. MUCH)

ACJavascript
06-29-2002, 02:01 AM
Glennv has the best idea here at the momment so, try this. Its bassed totaly of his script. Just add the full addy.

var lg = null;
function go(){
lg=window.open("page1.htm","GoPage")
}
function check(){

if (lg && !lg.closed && lg.location.href=="PutAddyHere"){
location.href="index.htm";
}else{
alert("Please click 'GO Here' first.");
}
}

</script>
</head>
<body>
<a href="javascript:go()">GO Here</a>
<a href="javascript:check()">Click here</a>
</body>
</html>

Hope this works ;)

twilight
06-29-2002, 10:30 AM
this still doesn't work :( :( :( everytime i give it a try with the full address i get an error in the line: if (lg && !lg.closed && lg.location.href=="http://strony.wp.pl/wp/twilight218/page2.htm"){ at column 1

'you're not entitled/no entitlement' - what does it mean :confused:

plz HEEEEEELP

ACJavascript
06-29-2002, 02:56 PM
OKay, well, I think checking for the location might not be the way to go. So I've put this together its like the first one i did with the hidden fields. It should work hehehe, but we all know how should never does. LOL.


-----------

<!doctype html public "-//w3c//dtd html 3.2//en">
<htmt>
<head>
<title>Windows</title>

<script language="javascript">

var url="page2.html"
function go(){

window.open(url,"page2")
document.forms[0].goTrue.value="true"
document.forms[0].goLoc.value=url
}
function check(){

if(document.forms[0].goTrue.value=="true" && document.forms[0].goLoc.value==url){
location.href="index.htm"
}else{
alert("Please Click - Go Here - First")
}

}
</script>
</head>
<body>

<form>
<input type="hidden" name="goTrue">
<input type="hidden" name="goLoc">
</form>

<a href="javascript:go()">Go Here</a>
<BR><BR>
<a href="javascript:check()">Click Here</a>

</body>
</html>

---------------

twilight
06-30-2002, 02:28 PM
'should never does' - that's good:) (that sould be a Murphy law - if it's not already)

well as you predicted it doesn't work:( the go() function puts document.forms[0].goTrue.value="true"
document.forms[0].goLoc.value=url
so after you click 'Go Here' you can immediately click on 'Click Here' without having to do anything in the newly open window (the user doesn't have to move from page1.htm to page2.htm - and that's what i'm trying to get here - the necessity of going from page1.htm to page2.htm)

i also tried the previous script you wrote (the one before the glenngv post) and it doesn't do the trick either.

another thing i tried was changing everything so that the code was frame-based (i used an iframe) and surprise surprise - it didn't work.

is it possible to make this work at all? (because i'm starting to loose faith)

ACJavascript
06-30-2002, 04:22 PM
NEVER EVER GIVE UP FAITH;)
There is always a way. ;)

Okay this should work(But it never does hehehe)

Just follow my instructions on how to install it.

-----------------------------
This page links to page1
When the user clicks the Go here they can't go there
So when the click - Click Here - true gets placed within the hidden form.
Now if they try to click - Go Here - now they still can't get in.
-----------------------------
<!doctype html public "-//w3c//dtd html 3.2//en">
<htmt>
<head>
<title>Windows</title>

<script language="javascript">
var url="page1.html"
function go(){

window.open(url,"page1")
document.forms[0].goTrue.value="true"
}
function check(){

if(document.forms[0].goTrue.value=="true" && document.forms[0].goLoc.value==url){
location.href="index.htm"
}else{
alert("Please Click - Go Here - First")
}

}
</script>
</head>
<body>

<form>
<input type="hidden" name="goTrue">
<input type="hidden" name="goLoc">
</form>

<a href="javascript:go()">Go Here</a>
<BR><BR>
<a href="javascript:check()">Click Here</a>

</body>
</html>

-------------------------------------------
Save this as page1.html, This page is the one that will link to page2.html
When the user clicks the link the - page2.html - is put within the goLoc hidden form on the first page. If the user go's back to the first page and clicks - Go Here - they will get in. This essentaily proves that they went to page1 & page2
----------------------------------------------

<title>Page 2</title>
<script language="javascript">

var url="page2.html"

function go(){
window.opener.document.forms[0].goLoc.value=url
}

</script>
</head>
<body>

<a href="javascript:go()">Click Here</a>

</body>
</html>


------------------------------


remeber never give up. ;)

glenngv
07-01-2002, 04:36 AM
don't use full url of page2.htm, that is why i used indexOf instead of comparing href to full url.

So use this code as it is:

var lg = null;
function go(){
lg=window.open("page1.htm","GoPage")
}
function check(){

if (lg && !lg.closed && lg.location.href.indexOf("/page2.htm")!=-1){
location.href="index.htm";
}else{
alert("Please click 'GO Here' first.");
}
}

</script>
</head>
<body>
<a href="javascript:go()">GO Here</a>
<a href="javascript:check()">Click here</a>
</body>
</html>

twilight
07-01-2002, 09:24 PM
still nothing:( :( :(

ACJavascript
07-01-2002, 09:28 PM
Did you try my script -- AC

If you did then i have some questions for ya hehe

Are you using frames?
Are you using iframes?
What browser Are you Using?


b/c when i tested the script and had friends test it to, it worked great.. so..........

glenngv
07-02-2002, 02:33 AM
i think you cannot access some properties of the window of another domain. it's a security issue.

So you have to settle with this:

var lg = null;
function go(){
lg=window.open("http://anotherdomain/page1.htm","GoPage")
}

function check(){
if (lg && !lg.closed){
location.href="http://mydomain/index.htm";
}else{
alert("Please click 'GO Here' first.");
}
}
</script>
</head>
<body>
<a href="javascript:go()">GO Here</a>
<a href="javascript:check()">Click here</a>
</body>
</html>

twilight
07-02-2002, 09:05 AM
AC i did preety heavy testing with everything you and Glenn wrote in this thread, but it doesn't exactly work for me.

the main problem is that i cannot edit page1.htm and page2.htm (i did that on my hdd and your code works great - that i do know). it's rather complicated but that's why i can't use your script. i thought that maybe Glenn could find a solution because his code didn't require editing page1/page2, but judging from what he wrote - he didn't:(

about your questions:
- i'm not using frames (although i tried changing the script like this: go() opens frame.htm where one of the frames is the ineditable page1.htm and the other frame contains the code that you told me to write on page1.htm - i thought it might work for me but after a few minutes i changed my mind because what i wanted to write was rather far from what i wanted to get: the necessity of clicking on page1 and moving to page2 - i just thought that i might check it when page1 will be in a frame but that didn't really work)
- i'm not using an iframe (well at least that wasn't my original plan - i also tried to change the code similar to the above)
- i'm using ie6

maybe now you'll be able to think of something but if you don't i will be forced to capitulate:(:(:(

glenngv
07-02-2002, 09:45 AM
as i said, you cannot access data from another domain. this is a cross-domain security issue.

for more of this, visit http://www.microsoft.com/technet/treeview/default.asp?url=/technet/security/bulletin/fq00-009.asp

twilight
07-02-2002, 10:44 AM
this explains everything:(
so maybe there is an anti-patch (or something) that removes the cross-domain security. i don't want to do anything bad - i'm not a 'malicious web site operator' :) and i certainly don't want to view anybodys files - i just wanna check if the address changed!!!

this sucks:mad: