How to intercept calls to open URLs?

Hi, all.

That’s my first post :smile:

I have an arcade website and it is full of Flash games.

When users click on Play More Games, they’re redirected to other sites.

I want to be able to capture the open link / open window on user’s browser and log the game name and target URL prior user leaves my site.

I want neither to prevent user from quitting my site nor interfere with game play. I just want to log data cited above.

Any idea on how to do it in JavaScript?

Thanks.

Hi plicatibu, welcome to the forum

It would be easy enough to use JavaScript to capture link click events and the link href values.

But, JavaScript can not directly write to the server.

It can however send the information to a server file that could write to a file or database.

Preliminary questions
What DOCTYPE are the pages?
Are you using jQuery?
What server-side language is the site, PHP?

You cant do it in JavaScript.Your visitor might have JavaScript turned off and the script would need to run something on the server to log the information anyway.

What you could do is to use a server side script that logs the information and then redirects to the external URL (similar to what some url shorteners do but using a script on your own site instead).

Thank you both for taking your time to reply.

Server is running PHP and I am using jquery.

I know JavaScript cannot directly log the data. My intension is to capture data and send it to server by issuing an AJAX call.

JavaScript for sure will be enabled (otherwise site doesn’t work).

My problem is how to intercept calls to open new.link / new window issued by Flash in order to collect data.

As felgall pointed out, JavaScript isn’t 100% reliable and can’t do it on its own.
But if you’re OK with that IMHO it should be doable

Ah, I missed that. A bit more complex than link clicks and link href values

Can you post a code sample of the HTML the Flash is in?

Below is an excerpt:

<div id="ava-game_container"><object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="800" height="600" id="ieID">
<param name="movie" value="http://freetycoongames.org/games/Ice-Cream-Truck.swf"/>
<!--[if !IE]>-->
<object type="application/x-shockwave-flash" data="http://freetycoongames.org/games/Ice-Cream-Truck.swf" width="800" height="600" id="eID">
<!--<![endif]-->
<!--[if !IE]>-->
</object>
<!--<![endif]-->

but I believe it won’t help because games in Flash, similar to Java applets, run in their own interpreter.

When Flash wants to open a link, it uses its integration with browser instead of doing it externally by calling JavaScript.

Also a growing number of browsers do not support Flash any more so the OP should look at replacing the Flash with something else if they want the site to work in the future.

@felgall You’re right Flash will eventually die but currently it’s still alive :slight_smile: and it’s very important to me to be able to gather the information asked above.

Any help is very much appreciated.

only in some browsers - and for security reasons it is currently recommended to NOT install it even in browsers that do allow it. Its death will be sooner rather than later - it is nearly dead now and certainly not worth developing anything new for as likely it will be dead by the time anything new is finished.

I’ve just spent some time trying to intercept object tag events using Firefox latest.

Nothing worked. :frowning:

First, I cleaned up the HTML
(I don’t understand the conditional comment “if not IE” as AFAIK only older versions of IE use them so it’s kind of like saying if it isn’t you, do this)

I tried click event on the container div
I tried fooling with z-index
I tried over-riding the native onmouseover
I tried specifying the declare attribute and linking to it

Personally I think your time would be better spent looking for alternatives for this quickly dying file format.

But if you really want to collect data, you could have each in its own page and intercept the clicks on the links that go to that page.

@felgall I understand your point of view but for me it’s important to achieve the task I am asking help for.

If Flash survived just 3 more months it would worth the effort (and I believe it will last for at least one year) :wink:

Unfortunately I can’t help you with your problem though as I have not had Flash installed on any browser for over a year (since back when I considered it was far too high a security risk to allow it to exist in any browser any more).

I seriously recommend that everyone uninstall Flash if they do still have it in order to remove one of the biggest security holes that currently exists.

@fegall thanks for your time.

@Mittineague Thank you for your effort in helping me.

I didn’t understand when you wrote “if you really want to collect data, you could have each in its own page and intercept the clicks on the links that go to that page.” (Sorry for my bad English)

Each game is in its own page, As Flash plugin calls open link / open windows directly from browser’s API .

I tried this but for.some reason (my lack of knowledge?) it didn’t worked.

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.