LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 10-08-2009, 02:47 AM   #1
johnh10000
Member
 
Registered: Nov 2008
Distribution: Ubuntu Lucid Lynx
Posts: 541

Rep: Reputation: 33
js html error trapping


Hi gang,

I'm looking for something that will do a redirect, if a url in an iframe returns an error.

Explain:
I have a webcam. which using motion, it gets a urlort on my lan. Now when I turn motion off, obvious, the urlort no loger there. What I want to do is when url there show it! When not there, show testcard. I have been fighting this for over a week. I have found stuff that will notifiy me of the error in JS, but still contiues to display can' connect or whatever it is, in the iframe.

Not bothered which lang. I can't do it in apach config, as far I can tell, as I only want the testcard, for the webcam!

Any ideas folks?
 
Old 10-08-2009, 02:54 AM   #2
smeezekitty
Senior Member
 
Registered: Sep 2009
Location: Washington U.S.
Distribution: M$ Windows / Debian / Ubuntu / DSL / many others
Posts: 2,339

Rep: Reputation: 231Reputation: 231Reputation: 231
what about
Code:
var f = <frame id>
if(<error>){f.src = <testcard url>}
remember that is missing the elements i cannot provide
 
Old 10-08-2009, 04:02 AM   #3
johnh10000
Member
 
Registered: Nov 2008
Distribution: Ubuntu Lucid Lynx
Posts: 541

Original Poster
Rep: Reputation: 33
Quote:
Originally Posted by smeezekitty View Post
what about
Code:
var f = <frame id>
if(<error>){f.src = <testcard url>}
remember that is missing the elements i cannot provide
I have turned off motion here's the error,
Failed to Connect

The connection was refused when attempting to contact 192.168.1.3:8800.
Though the site seems valid, the browser was unable to establish a connection.

* Could the site be temporarily unavailable? Try again later.
* Are you unable to browse other sites? Check the computer's network connection.
* Is your computer or network protected by a firewall or proxy? Incorrect settings can interfere with Web browsing.

so how do i check for that?
Code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
  <title>Untitled Document</title>
  <meta http-equiv="Content-Type"
 content="text/html; charset=iso-8859-1">
<head>
<script type="text/javascript">
function timedMsg()
{
var t=setTimeout("window.location.reload()",(60000*6));  //every 6 mins
}
</script>
</head>
<body onload="timedMsg()" bgcolor="#6699ff">
<div align="center">
<p><font face="Courier New, Courier, mono"><b><font color="#00ffff"
 size="+7">Webcam</font></b></font></p>
<div style="text-align: center;"><span style="color: black;"> <br>

Last Updated:
<br>

<script type="text/javascript" language="JavaScript1.1">
      <!-- 
          
      lastmod = document.lastModified     // get string of last modified date 
      lastmoddate = Date.parse(lastmod)   // convert modified string to date
      if(lastmoddate == 0){               // unknown date (or January 1, 1970 GMT)
         document.writeln("Unknown")
      } else {
      d = new Date(lastmod);
      document.write(d);
      }// -->
    </script>
</span><br>
<br>
<table style="text-align: left; width: 100%;" border="1" cellpadding="2"
 cellspacing="2">
  <tbody>
    <tr>
      <td
 style="vertical-align: top; text-align: center; background-color: rgb(255, 204, 0);">Live
Webcam<br>
      </td>

      <td
 style="vertical-align: top; text-align: center; background-color: rgb(255, 204, 0);">Last
Snap reloaded every 6 mins<br>

      </td>
    </tr>
    <tr>
      <td style="text-align: center; vertical-align: top;"> <iframe
 id="myFrameL" src="http://192.168.1.3:8800/" height="256" width="338"> If you can
see this, your browser doesn't understand IFRAMEs. 
</iframe> 
</td>
<td style="text-align: center; vertical-align: top;"> <iframe
 id="myFrameR" src="http://192.168.1.3/webcam/lastpic.jpeg" height="256" width="338">
If you can see this, your browser doesn't understand IFRAMEs.

      </iframe> <br>

      </td>

    </tr>
  </tbody>
</table>
<br>
<br>
</div>
<div id="top"></div>
<div style="text-align: center;"><a
 href="http://www.freesitemapgenerator.com/"><img
 alt="Free Sitemap Generator"
 style="border: 0pt none ; margin: 3px; padding: 0pt;"
 src="http://live.freesitemapgenerator.com/img/fsgbig41.gif" border="0"></a></div>
<script language="javascript">
/* FSG 0.96 script */ 
var fsg_Live_date_package_version='0.96';
var fsg_image = 'big4';
var fsg_serial = 'b816a328c80a0b3c1fe4c083ac851ed6';
</script>
<script language="javascript"
 src="http://live.freesitemapgenerator.com/scripts/fsg096.js"></script></div>

</body>
</html>
cheers
 
Old 10-08-2009, 04:56 AM   #4
zhjim
Senior Member
 
Registered: Oct 2004
Distribution: Debian Squeeze x86_64
Posts: 1,748
Blog Entries: 11

Rep: Reputation: 233Reputation: 233Reputation: 233
I bet the easiest way would be with a custom error page from the apache

http://httpd.apache.org/docs/2.2/custom-error.html
scroll down to "Configuration"
http://httpd.apache.org/docs/2.2/mod...#errordocument

Just put this into a <Directory> directive or just for the <File>

Cheers zhjim
 
Old 10-08-2009, 10:17 AM   #5
johnh10000
Member
 
Registered: Nov 2008
Distribution: Ubuntu Lucid Lynx
Posts: 541

Original Poster
Rep: Reputation: 33
Quote:
Originally Posted by zhjim View Post
I bet the easiest way would be with a custom error page from the apache

http://httpd.apache.org/docs/2.2/custom-error.html
scroll down to "Configuration"
http://httpd.apache.org/docs/2.2/mod...#errordocument

Just put this into a <Directory> directive or just for the <File>

Cheers zhjim
Thanks for that it's sort of working, this way. Just one minor problem.
When the webcam server is tuned off it produces a "Failed to Connect" error. Ilooked this up on google, and it says it's 503 error. Which I have now suposidly trapped, but I haven't, any ideas on that?

And yes you win your bet, it is easier. (Well when I remmember, the webcam is comming from a differant box!!)
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
'trapping' relayed messages turbo_acura Linux - Networking 0 03-27-2009 05:26 AM
Trapping control-c for netcat Oxagast Linux - Software 4 04-01-2008 12:39 AM
ksh Error trapping/logging Risc91 AIX 1 07-28-2005 10:31 PM
trapping packets mohit_garg Linux - Networking 6 07-10-2005 05:29 PM
Trapping keystrokes in C k4zau Programming 3 03-09-2003 01:13 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 12:11 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration