Posted by McBeaver in SWF Studio V3 on Jan 27 2008, 06:38 pm

I am trying to account for a web page that can't be reached. The kjiosk is running off a wireless card, so it would probably be due to a cellular blind spot vs. the page actually being down. Using the event:

ssCore.Browser.setNotify({event:"onDocumentComplete"}, {callback:onDocComplete});

I am trying to see an error come in if the page loading has an issue. I am testing it by putting in a fake url. Using:

function onDocComplete(ret_obj, cb_obj, err_obj) {
ssDebug.trace("code:" + err_obj.code);
ssDebug.trace("description:" + err_obj.description);
...
}
error_obj.code returns a 0 no matter what, and ret_obj.success is always true. Am I using it wrong?

Also, can I set the home page of the browser through the API?

Thanks.


Posted by northcode in SWF Studio V3 on Jan 27 2008, 11:09 pm

The home page can set by modifying the following registry entry.

[HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\Main]
"Start Page"="http://www.northcode.com"

This code should do the trick.


ssCore.Registry.setValue({rootKey:"HKEY_CURRENT_USER", subKey:"Software\\Microsoft\\Internet Explorer\\Main", valueName:"StartPage", type:"REG_SZ", value:"http://www.northcode.com"});


Using onDocumentComplete to detect errors in page loads isn't going to work. That event is fired when a page load is complete, it could be a 404 page, the result of a redirect, etc. You could check to see if the URL that onDocumentComplete is passed is the one you were looking for, but the effect of server side redirects and other things will make this very tricky to get working.

What you probably want to do is try to load the page with the HTTP plugin and look at the header you get back to see if you get an OK or some kind of error.


Posted by McBeaver in SWF Studio V3 on Jan 27 2008, 11:19 pm

Is there a sample file for using the http plugin? Is it more efficient/faster than the browser? Because the kiosk is connected wirelessly (EVDO I believe), and moving, and behind a proxy, is this the way to go? Thanks!


Posted by northcode in SWF Studio V3 on Jan 28 2008, 10:07 am

The Download a File example should do what you want.

If you don't provide a local file name as a destination for the HTTP operation (like this example does) then you can retrieve the downloaded content using the HTTP.getBuffer command.

Calling HTTP.getHeaders (can be called after a successful call to HTTP.start) returns a string of HTTP headers separated by newlines. This is where you'll find out whether the download returned a 404 (not found), 200 (OK) or something else.

The HTTP plugin will be faster than the browser because it has less startup overhead. It also doesn't require you to download the entire page if all you want to do is check to see if it's there (which you can do by looking at the headers).


Posted by McBeaver in SWF Studio V3 on Jan 28 2008, 10:52 am

...and then the content is displayed in the browser object, or it can display itself?


Posted by northcode in SWF Studio V3 on Jan 28 2008, 04:10 pm

The HTTP plugin is for working at the HTTP level only (getting/sending data) it has no display capabilities. I recommended it only as a means of checking for bad pages before you try to display them, assuming that you wanted to hide errors like that from users. If your users are okay with standard web 404 pages etc, then you really don't need the HTTP plugin, just let the page load in the browser object fail "normally".


Posted by McBeaver in SWF Studio V3 on Jan 28 2008, 04:25 pm

Can I overwrite any of the browser error pages (probably not a 404, but maybe no connection) to show a local html w/o the http plugin?


Posted by northcode in SWF Studio V3 on Jan 28 2008, 04:52 pm

You can tell IE to display "friendly error" messages by tweaking the registry. From there you can probably replace the friendly message with your own (if you can find the local copy that IE uses), but I've never tried this.


Posted by McBeaver in SWF Studio V3 on Jan 28 2008, 08:37 pm

Thanks for all the info!


Posted by McBeaver in SWF Studio V3 on Jan 29 2008, 03:13 am

So the code I have been testing has been:



 ssCore.Registry.setValue({rootKey:"HKEY_CURRENT_USER", subKey:"Software\\Microsoft\\Internet Explorer\\Main", valueName:"Start Page", type:"REG_SZ", value:ssGlobals.ssStartDir+"\\home.html"});
 ssCore.Registry.setValue({rootKey:"HKEY_LOCAL_MACHINE", subKey:"Software\\Microsoft\\Internet Explorer\\AboutURLs", valueName:"DesktopItemNavigationFailure", type:"REG_SZ", value:ssGlobals.ssStartDir+"\\error.html"});
 ssCore.Registry.setValue({rootKey:"HKEY_LOCAL_MACHINE", subKey:"Software\\Microsoft\\Internet Explorer\\AboutURLs", valueName:"NavigationCanceled", type:"REG_SZ", value:ssGlobals.ssStartDir+"\\error.html"});
 ssCore.Registry.setValue({rootKey:"HKEY_LOCAL_MACHINE", subKey:"Software\\Microsoft\\Internet Explorer\\AboutURLs", valueName:"NavigationFailure", type:"REG_SZ", value:ssGlobals.ssStartDir+"\\error.html"});
 ssCore.Registry.setValue({rootKey:"HKEY_LOCAL_MACHINE", subKey:"Software\\Microsoft\\Internet Explorer\\AboutURLs", valueName:"PostNotCached", type:"REG_SZ", value:ssGlobals.ssStartDir+"\\error.html"});
  


I figured I'd set all keys that looked like possible errors to my custom html. After a lot of googling, turns out I can't change HKEY_LOCAL_MACHINE as a non-admin. I can change HKEY_CURRENT_USER so that's why the home page works. I tried editing shdoclc.dll as well but can't overwrite the file (the kiosk uses IE6). Any ideas for a workaround other than the httpPlugin... although that's my next step anyway. I'm just curious at this point more than anything, using the httpPlugin will probably be far quicker than the time I just wasted :)

Will using the plugin to check for errors then actually calling the browser on success be double time/bandwidth? Things are slow enough already on this thing, don't want to bog it down even more.


Posted by northcode in SWF Studio V3 on Jan 29 2008, 09:49 am

Even if they aren't "advertised", it has been my experience that there are usually HKCU versions of most HKLM registry settings in Microsoft software so you might want to try that first.

The HTTP plugin may slow things down but you don't have to actually download the page, you just have to request the page and read the headers. The headers are available once HTTP.start returns so you shouldn't have to do the HTTP.read.

You can even call HTTP.start synchronously, but that's a little risky if the site is really down.


Posted by McBeaver in SWF Studio V3 on Jan 29 2008, 11:07 am

I was up all night trying HKCU versions. Home page worked, while local page doesnt, none of those abouturls worked... I'm waiting to hear if I can runas admin to insert them... we'll see. Thanks.