nop_90

I have pages that look like this
<html>
<head>
<script>
XXXXX send info to another server
document.location = "XXXXX";
</script>
</head>
............
I have no control over the server. I can only do JS.
Before I hit document.location I want info to be sent to another server which i do control.
The document.location has to be in the head part of page, because i want the redirect to happen,
before page has completely loaded.

Any ideas ?

perkiset

There are 2 issues here.

First is the multiple domain bit - can't use

Ajax

  - it's single domain. iFrames will work, and images (my personal choice) will work but...
Second problem: IE particularly will stop loading things and resources the moment it notices that it is leaving the current page.

IE., as soon as you say top/document.location, will abandon any loading operation - it will even stop animating GIFs. This would not be a problem, except that inline code in the header is going to go really fast, and it is a sure bet that the JS will get to the change in location line before it has fired off the thread to go get <the whatever that is your beacon>. The real problem here is that

Javascript

  does not offer a blocking Sleep-like function. The only way to delay execution in JS is to either set a timeout or an interval. One other technique is to not count on a delay, but rather to count on a completion ie., when something is all done. The problem here, is that your page will have loaded before the timeout/event pops.  There are a couple ways to obscure the PERCEPTION of the page loading... we can handle that in a bit ...

but assuming that we do, here's my suggestion for the dandelion (my personal nom-de-technique for little uni-directional snippets of information blowing towards my server from the client):

I'm thinking you need to create an image and load it inline:

myImage = new Image();
myImage.onLoad = function() { top.location = 'http://anotherdomain.com'; }
myImage.src = 'http://nopsDomain.com/aURL.

php

 ?parm1=this&parm2=that';
// obviously, where the url above is a string construct of the data you want to pass...

this, put in the header, will fire off an immediate request for a graphic - in fact, since it is in the header it will be before any other requests for graphics have fired off. It will be very fast, BUT the browser will have gotten and started to render your HTML before it arrives. Note that I think you should have a 1x1 pixel .GIF that you return to absolutely maximize the speed at which you will respond to the event. I like this method because it will move as quickly as possible, regardless of connection or

mac

 hine speed.

Now... what's the problem with cloaking/hiding/obscurring the page content? Why can't we do a little JS and obscure the opening of the page?

/p

thedarkness

Anotehr approach would be to do your "document.location = " to a page on the server you do control including the parameters you want to pass and the ultimate url you want to redirect to then issue a redirect from there. This approach has downsides (loss of referrer, etc. ) and I'm sure you've considered (and discounted) it but I offer it up for someone in a similar situation where it presents a viable option.

Cheers,
td

nop_90

I tried doing a normal <img src="http://XXXX>
then i tried with a CSS style file.
But exactly what u say happens. the page redirects before the image/file even starts to load.


myImage = new Image();
myImage.onLoad = function() { top.location = 'anotherdomain.com'; }
myImage.src = 'nopsDomain.com/aURL.

php

 ?parm1=this&parm2=that';
// obviously, where the url above is a string construct of the data you want to pass...

It will work thanx Applause
I should be also able to put an onError so if my server is down then i will still redirect.

quote author=perkiset link=topic=99.msg457#msg457 date=1177478181

Now... what's the problem with cloaking/hiding/obscurring the page content? Why can't we do a little JS and obscure the opening of the page?


Errrrr yah
it is for my son's science fair project where yah the page gets redirected to one of those places where hopefully user
is running IE6 and 20 popups nail them. And part of the science project is user should not know what is happening.
Yah thats it.

perkiset

quote author=nop_90 link=topic=99.msg468#msg468 date=1177479479

Errrrr yah
it is for my son's science fair project where yah the page gets redirected to one of those places where hopefully user
is running IE6 and 20 popups nail them. And part of the science project is user should not know what is happening.
Yah thats it.


I thought that was it  Applause

nop_90

quote author=thedarkness link=topic=99.msg467#msg467 date=1177479464

Anotehr approach would be to do your "document.location = " to a page on the server you do control including the parameters you want to pass and the ultimate url you want to redirect to then issue a redirect from there. This approach has downsides (loss of referrer, etc. ) and I'm sure you've considered (and discounted) it but I offer it up for someone in a similar situation where it presents a viable option.

Problem is my vps is unreliable, so if it is down then i lose the user.


Perkiset's Place Home   Politics @ Perkiset's