Following a recent a brief server outage I have been tinkering with an approach to solve problems that might occur on external sites using our Feed2JS service. I’m lookng for some folks willing to test some extra JavaScript aimed at preventing page hangs should we blink out on you.
Here is the issue. The whole magic works because your web pages are looking to link to an extneral file of JavaScript commands that output the content. Typically this is done as a link toa file, say of some common routines used on many pages, so the JavaScript is linked via a command like:
<script language="JavaScript" src="../js-lib/cool-functions.js" type="text/javascript"></script>
Feed2JS does the same, except the src= points to a script which dynamically builds the JavaScript output statements. The problem is what if the URL in the src= tag is not available? It does not seem to time out the browser, like an unfound link, and for many users, their browser is stopped from displaying any content. Bad mojo, indeed.
Since moving my web development to PHP a few years back, I avoid where ever I can using JavaScript- it is just too browser dependent, prone to idiosynchrocies, and always feels like a “kludge” approach. But sometimes, it is the only recourse. So the end around I am trying would go through a process like this as a Feed2JS page loads:
- Javascript first turns a flag variable to “off” to indicate we have not heard back yet from the Feed2JS server.
- Javascript starts a timer that goes off in say, 15 seconds. If the flag variable has been flipped “on”, we de-activate the timer, If it is still in the “off” position, it means we have not heard back from the server. So we pop up a confirmation box, asking the user if they want to try another 15 seconds, or to cancel the request. Here is where it gets tricky– there does not seem to be a 100% reliable way to have JavaScript tell the browser to abort the transaction, the equivalent of hitting the “stop” button on the browser. The methods I dug up include:
- For NetScape/Mozilla/FireFox:
window.stop()
- For IE, there is an undocumented but-sits-on-Microsoft’s-site command:
document.execCommand('Stop');
- For Safari, well neither seems to work.
So The confirmation box let’s the user know it will try and stop the browser, but it may fall on the user top do it manually. At least the get a message that feed2JS is OOC (out of commission).
- For NetScape/Mozilla/FireFox:
- The current Feed2JS script is set now to return to all requests, a JavaScript command that sets the variable in step 1 flip to the flag variable to the “on” position (see an example of the raw JavaScript output) — this has no effect on anyone’s current use of Feed2JS.
So below is some HTML to test this functionality out:
I am providing a zipped template of my test file. I am just looking to try this out before rolling it in as the standard template (it would not be required, but optional). Or if anyone has some JavaScript insight as to a better way to do this, please let me know. Thanks!
Trying to send feedback via form page but getting an error preventing me from doing so….
A fatal error occurred on form input. No recovery possible. Status code: 4536X33369
So please pardon the intrusion, but I do not know how to otherwise reach you.
Ok – I really tried not to bother you folks – but this is where I am at – Magpie works – debug scripts, etc. tell me I am good. Cache directory is set and I can even see files being written to it. BUT… when I run build.php – I do not get a preview screen – click on test/debug and I can view the feed. Does not give me any error codes to debug. Go generate script and it does so, but actual code will not produce a feed at all. Site – http://rssfeed.xeod.net – you will be able to see the directory structure, etc. I am at a loss as to where to check next. Test page with feed code – http://www.dvol.com/testrss.html
If I put code line in to browser
http://rssfeed.xeod.net/feed2js.php?src=http%3A%2F%2Fwww.teenboard.com%2Fteenblog%2Findex.rdf&num=6&targ=y
get the following….
Warning: Cannot modify header information – headers already sent by (output started at /home/xeodnet/public_html/rssfeed/magpie/rss_fetch.inc:459) in /home/xeodnet/public_html/rssfeed/feed2js.php on line 278
document.write(‘
‘); document.write(‘
* ‘); document.write(‘Ruffles; A Fashionable Girls Best Friend
‘); document.write(‘
* ‘); document.write(‘Teen Board Members to appear on CN8 TV
‘); document.write(‘
* ‘); document.write(‘A plea from one mom for this holiday
‘); document.write(‘
* ‘); document.write(‘Teens Deck Their Cell Phones with Sounds of Christmas
‘); document.write(‘
* ‘); document.write(‘ Teen Board Programs Seeking New Applicants for 2005
‘); document.write(‘
* ‘); document.write(‘Winter 2004 Trends
‘); document.write(‘
‘); document.write(‘
‘);
It’s probably something stupid on our end, but 2 programmers have looked at it and we are stumped.
Thanks in advance