473,288 Members | 1,794 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,288 software developers and data experts.

Javascript load external URL's?

Okay, this involves integrating javascript with PHP (though you don't
have to know PHP to understand my question.)

I have a page. It has a link. When someoen clicks on the link, iw ant
to know. But- it's an OFFSITE link. Fundamentally untrackable.

This is my comprimise... when you click on that link, Javascript
executes a function in half-second before the page unloads. That
fuction loads an external image. (purely into memory with a .src=) I'm
using PHP to coun the number of times that image is loaded.

This works, for the most part. but my code looks like-

teston.src = "test.php?mode=increment";

(The query mode set after the file name is what tells php to increment
the databse, clearly.)

Now- here's the crux- there's no fundamental need for this to be an
image. (text.php actually returns blank, it doesnt' bother sendign an
image file.) Is there a way OTHER than using image.src to send a
http:// query out of Javascript? (I know there must be, but my js is
SOO rusty, last time I coded heavily was when Netscape introduced their
now-depricated layers implementation.)

Also- is there a... better way to do this? This seems like the only
possible way to tackle this, but I'm operatining the dark here. I
assume someoen else has tried this before me.

-Derik

May 17 '06 #1
4 16363
Re********@aol.com wrote:
Okay, this involves integrating javascript with PHP (though you don't
have to know PHP to understand my question.)

I have a page. It has a link. When someoen clicks on the link, iw ant
to know. But- it's an OFFSITE link. Fundamentally untrackable.

This is my comprimise... when you click on that link, Javascript
executes a function in half-second before the page unloads. That
fuction loads an external image. (purely into memory with a .src=) I'm
using PHP to coun the number of times that image is loaded.

This works, for the most part. but my code looks like-

teston.src = "test.php?mode=increment";

(The query mode set after the file name is what tells php to increment
the databse, clearly.)

Now- here's the crux- there's no fundamental need for this to be an
image. (text.php actually returns blank, it doesnt' bother sendign an
image file.) Is there a way OTHER than using image.src to send a
http:// query out of Javascript? (I know there must be, but my js is
SOO rusty, last time I coded heavily was when Netscape introduced their
now-depricated layers implementation.)

Also- is there a... better way to do this? This seems like the only
possible way to tackle this, but I'm operatining the dark here. I
assume someoen else has tried this before me.

-Derik


Hi Derik,

You have several other options, allthough I do not understand why you
image-source switch doesn't work. (It should).

Alternatively:
1) Use a hidden frames.
2) Use Ajax.

If you are unfamiliar with AJAX, start here for a great tutorial to master
the Ajaxbasics in one hour: www.w3schools.com/ajax

Regards,
Erwin Moller
May 17 '06 #2
>You have several other options, allthough I do not understand why you
image-source switch doesn't work. (It should).
It does work- I find it inelegant to be using an image construct to
load a non-image, and am wondering if I can load this URL (well, quwery
it, since it never actually loads anything, the magic is in makign the
request) withotu creatign the javascript image construct.

In short- I'm wondering if there's a more 'mature' implementation of
this approach.
Alternatively:
1) Use a hidden frames.
Pfft, and leave the user stuck int he frame when clicking out? No way.
2) Use Ajax.


*looks at Ajax*

Yeah, that's what I'm looking for. A more mature, elegant application
of the same technologies involved. ;-)

Thanks!

-Derik

May 17 '06 #3
Re********@aol.com said the following on 5/17/2006 4:46 PM:
You have several other options, allthough I do not understand why you
image-source switch doesn't work. (It should).
It does work- I find it inelegant to be using an image construct to
load a non-image, and am wondering if I can load this URL (well, quwery
it, since it never actually loads anything, the magic is in makign the
request) withotu creatign the javascript image construct.


What is so "inelegant" about an approach that is almost fool proof?
In short- I'm wondering if there's a more 'mature' implementation of
this approach.
Alternatively:
1) Use a hidden frames.


Pfft, and leave the user stuck int he frame when clicking out? No way.
2) Use Ajax.


*looks at Ajax*

Yeah, that's what I'm looking for. A more mature, elegant application
of the same technologies involved. ;-)


Two things:
1) It is *not* the same technologies
2) With that "mature elegance", you lose reliability.

--
Randy
comp.lang.javascript FAQ - http://jibbering.com/faq & newsgroup weekly
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
May 17 '06 #4
Randy Webb wrote:
Re********@aol.com said the following on 5/17/2006 4:46 PM:
You have several other options, allthough I do not understand why you
image-source switch doesn't work. (It should).


It does work- I find it inelegant to be using an image construct to
load a non-image, and am wondering if I can load this URL (well, quwery
it, since it never actually loads anything, the magic is in makign the
request) withotu creatign the javascript image construct.


What is so "inelegant" about an approach that is almost fool proof?
In short- I'm wondering if there's a more 'mature' implementation of
this approach.
Alternatively:
1) Use a hidden frames.


Pfft, and leave the user stuck int he frame when clicking out? No way.
2) Use Ajax.


*looks at Ajax*

Yeah, that's what I'm looking for. A more mature, elegant application
of the same technologies involved. ;-)


Two things:
1) It is *not* the same technologies
2) With that "mature elegance", you lose reliability.


Yep, I second Randy's opinion completely.

About the hidden frame: The user will NOT EVEN notice it, let alone (s)he is
stuck in it.
A hidden frame is just a frame with 0 for width or height.
You change the location/URL of that frame, so it loads a new page, in this
case you just call your script.
The user won't notice and won't see a thing. (Only the animation in some
browsers indicating some networkactivity is going on.)

I agree however, for other reasons, that frames should be avoided.

If you choose to go Ajax, be aware that this will only work on modern
browsers, the ones that support some implementation of a httpxmlObject, or
whatever they are called on the different browsers.

The trick with the image works on all browsers.

Also be aware that all tricks/solutions discussed so far ALL rely on
Javascript, which is disabled by some.
If you want to count ALL your clicks (also the ones from browsers that have
JS disabled), you have little more choice than hitting the page that counts
directly, and let it redirect to the 'real' location when the increasing is
done.

Good luck.

Regards,
Erwin Moller
May 18 '06 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: ICode | last post by:
Hi, all, I am currently updating links for a site almost daily. I have set the META tags to allow for no caching so that as soon as the site is updated on the server, the new changes can be...
5
by: joaopedrogoncalves | last post by:
Hi, I want to load an external javascript file, get its results and stick them inside a <div> block. I also want to do this in several places on a web page. This way the browser doesn't have...
15
by: binnyva | last post by:
Hello Everyone, I have just compleated a JavaScript tutorial and publishing the draft(or the beta version, as I like to call it) for review. This is not open to public yet. The Tutorial is...
6
by: sylcheung | last post by:
Hi, How can I be notified when the document load is complet in JavaScript? I am referring to the whold document load is complete, mean all images/external files/frame/iframes have been loaded. ...
5
by: punchbag | last post by:
Hi all, There has recently been a new update to internet explorer whereby activex controls now load on a page unactivated. MSDN have a website explaining a workaround where you do away with the...
1
by: ozzy.osborn | last post by:
Hello All, I have been struggling with a cross browser solution to loading external javascript files on the fly. I have been successful using the following code in IE6: var newScr =...
2
by: Dave Mathew | last post by:
I'm trying to run some clientside javascript on page load for one of my ASP.Net pages. I am using the ClientScript.RegisterClient....() methods to register an external javascript file within...
1
by: JohnnieTech | last post by:
I am using some javascript/ajax to load content into a main div. The problem I am running into is that it will work in IE but not in FF. In FF I don't get any sort of load at all. I have a 1...
20
RMWChaos
by: RMWChaos | last post by:
Currently testing in: WinVista / IE7 I have been working on getting xmlhttprequest going for weeks now. I have finally gotten a semi-working script going. Pulling up text or xml files works great...
3
by: pjdelaere | last post by:
Hi, In a multiuser environment the following happens: for one user I load a page that contains external, internal and inline javascript; all runs well. If I load new internal or inline...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: Aftab Ahmad | last post by:
So, I have written a code for a cmd called "Send WhatsApp Message" to open and send WhatsApp messaage. The code is given below. Dim IE As Object Set IE =...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
by: marcoviolo | last post by:
Dear all, I would like to implement on my worksheet an vlookup dynamic , that consider a change of pivot excel via win32com, from an external excel (without open it) and save the new file into a...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.