Windows 8 app javascript Redirect “immediately”

I've got this:

try{var conn = new WebSocket('ws://' + sessionStorage.ip + ':5565');}
catch (Exception) {location = "error.html";}

I would expect this to redirect me as soon as it reaches location = "error.html"

Later on in the script I have:

conn.onopen = {blah blah

But it crashes with

0x800a138f - JavaScript runtime error: Unable to set property 'onopen' of undefined or null reference

So the websocket isn't being created, and while the catch does get the exception, it doesn't redirect immediately, instead continuing on for a bit until the actual redirection.

How do I fix this?


I previously had the redirect in the <body> tag.

        location = "error.html"

I should have had it in the <head>

        location = "error.html"

Need Your Help

How to test RESTful call to database without seeding data?

ruby-on-rails angularjs rspec capybara poltergeist

I have a dropdown box that is populated using data from the database (via Angular).

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.