/    Sign up×
Community /Pin to ProfileBookmark

Can external javascript process my URLs?

I have a 900+ row MySQL database, comprising 15 categories of site_name and URL details, dynamically accessed using a series of selects. These pages retrieved by these URLs are copied into the main contents frame of my home page. I am receiving a healthy number of hits each day but am unable to determine which links are most/least popular.
I have hit the problem of storing the contents of parent.contents.location.href for further use I would like to either write them to a text file or directly back into MySQL for analysis purposes.

The select code follows:
(The $a is passed into the function as the value of [I]site_code,[/I] which is not retrieved)

$result_recordset=$db->Execute(“select distinct site_name,site_link
from site_list
where site_code=’$a’
and site_name is not null
and active = ‘Y’
order by site_name”);
?>
<FORM action=”get”>
<select [B]onChange=”parent.contents.location.href=options[selectedIndex].value;”>[/B]
<?php
while(!$result_recordset->EOF)
{
echo(“<option value ='”.$result_recordset->fields[‘site_link’].”‘> “.$result_recordset->fields[‘site_name’]);
$result_recordset->MoveNext();
}
unset($result);
echo(“</select>”);
$result.close;

Is there any realistic chance of being able to pass the URL to an external javascript or php file for processing and preservation or am I flogging a dead horse and should consider a total rethink? I have no access to ASP or VB so am confined to PHP/Javascript/MySQL (not really a limitation!)
The use of a separate SUBMIT button to perform a GET or POST would not suit the architecture as it now exists.

Thanks for any help you guys can offer.

to post a comment
JavaScript

5 Comments(s)

Copy linkTweet thisAlerts:
@WolfShadeMay 25.2011 — You could set the onChange to go to an HTML or PHP page with the site URL as a parameter, do whatever javascript or PHP you want with it, then redirect to the site.
Copy linkTweet thisAlerts:
@macca1ianauthorMay 25.2011 — I didn't know whether an 'intermediate page' would do the trick. I guess you mean to use it as a 'black box' and 'dump' the data there en-route to the 'proper page' that would possibly solve things. Thanks for that! I'll give it a whirl.
Copy linkTweet thisAlerts:
@rnd_meMay 25.2011 — use anchors instead of onclicks so you can use the ping attrib.

or, simply add google analytics to each page review the nice colorful graphs of visitor stats google provides for free.
Copy linkTweet thisAlerts:
@WolfShadeMay 25.2011 — Well... I don't know about 'black box'; but 'dumping' the data sounds about right.

The important thing is that everything except going to the site URL will be behind the scenes; and unless there is a TON of data, or a lousy internet connection, or something bottlenecking the data, it should process invisibly to the user - from their point of view, it just goes to that site, nothing more.
Copy linkTweet thisAlerts:
@macca1ianauthorMay 26.2011 — Hi

Thanks for the suggestions guys. Sorry about the late reply. I think my ISP has an issue with superglobals like $_GET, having upgraded to PHP5, so I'm trying to either get them turned back on or I'll have to have a workaround.

I'll keep you posted on the eventual solution but I'm looking at getting the data passed to a javascript function using "this" and then calling the external php page from there having assigned parent.location.href to Result and passing

location.href="page2.php?Result=" + Result;

to the external php.

This is new territory for me....trying to 'marry' client-side and server-side seems like a minefield!
×

Success!

Help @macca1ian spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 6.16,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @nearjob,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,
)...