test page 3 - Dave's Blog

Search
My timeline on Mastodon

TED Blog | The greatest TED Talk ever sold: Morgan Spurlock on TED.com

2011 Apr 6, 3:49 PermalinkCommentshumor video morgan-spurlock ted advertising ad

JavaScript & .NET interop via WebBrowser Control

2011 Apr 5, 10:00

For my GeolocMock weekend project I intended to use the Bing Maps API to display a map in a WebBrowser control and allow the user to interact with that to select a location to be consumed by my application. Getting my .NET code to talk to the JavaScript in the WebBrowser control was surprisingly easy.

To have .NET execute JavaScript code you can use the InvokeScript method passing the name of the JavaScript function to execute and an object array of parameters to pass:

this.webBrowser2.Document.InvokeScript("onLocationStateChanged",
new object[] {
latitudeTextBoxText,
longitudeTextBoxText,
altitudeTextBoxText,
uncertaintyTextBoxText
});

The other direction, having JavaScript call into .NET is slightly more complicated but still pretty easy as far as language interop goes. The first step is to mark your assembly as ComVisible so that it can interact with JavaScript via COM. VS had already added a ComVisible declaration to my project I just had to change the value to true.

[assembly: ComVisible(true)]

Next set ObjectForScripting attribute to the object you want to expose to JavaScript.

this.webBrowser2.ObjectForScripting = this.locationState;

Now that object is exposed as window.external in JavaScript and you can call methods on it.

window.external.Set(lat, long, alt, gUncert);

However you don't seem to be able to test for the existence of methods off of it. For example the following JavaScript generates an exception for me even though I have a Set method:

if (window.external && window.external.Set) {
PermalinkCommentsjavascript webbrowser .net technical csharp

Mind vs. Machine - Magazine - The Atlantic

2011 Feb 17, 1:01Brian Christian on his involvement in the 2009 Turing Test and his goal of winning Most Human Human.PermalinkCommentshistory ai science

zerodaythebook.com

2011 Jan 23, 4:49Sysinternals Mark Russinovich writes a novel (fiction) and gets a Bill Gates blurb for the cover: “Mark came to Microsoft in 2006 to help advance the state of the art of Windows, now in his latest compelling creation he is raising awareness of the all too real threat of cyberterrorism.” —Bill GatesPermalinkCommentsbook security microsoft sysinternals mark-russinovich novel fiction technical

Conan O’Brien Presents Show Zero – The Fastest Talk Show Ever

2010 Nov 2, 9:16PermalinkCommentsvideo conan-obrien talk-show humor tv

C-SPAN Video Player - House Judiciary Subcmte. Hearing on Immigration and Farm Labor

2010 Sep 24, 8:38"Comedian Stephen Colbert joined the panel of witnesses at a House hearing on immigrant farm workers. Mr. Colbert has partnered with United Farm Workers and their campaign calling on unemployed Americans to take jobs in the agriculture sector. The organization's president, Arturo Rodriguez, also testified at the Judiciary Subcommittee on Immigration and Border Security hearing chaired by Rep. Zoe Lofgren (D-CA).
Washington, DC : 2 hr. 10 min."PermalinkCommentshumor video stephen-colbert politics immigration farm labor house

Make: Online : Hand lights — Cool Tools contest winner

2010 Sep 14, 2:24Good idea and solves some of the head lamp problems: "...Enter the Hand Lights, a pretty simple and cheap DIY project that puts adjustable lights on your forearms to light whatever is in your hands."PermalinkCommentslight diy hand head-lamp tool

Make: Online : How-To: Personal Applause Sign

2010 Jul 14, 10:24This would be perfect to hook up to my automated test system. Everytime new tests pass the applause sign flashes.PermalinkCommentsapplause sign howto

The State of Web Development 2010 – Web Directions

2010 Apr 29, 11:51Stats from the State of Web Development 2010 web survey including: "Few respondents use any form of Internet Explorer for their day to day web use, but IE8 is the number one browser developers test their sites in. Google Chrome has jumped dramatically as the browser of choice for developers, to rank 3rd, at 17% just behind Safari at 20%."PermalinkCommentsie web browser chrome statistics development html technical system:filetype:pdf system:media:document

Ajaxian » Put your own tests up on BrowserScope

2010 Apr 21, 6:53"Lindsey Simon has got a powerful update to BrowserScope, the community-driven tool to test and profile browsers. The new feature is exciting as it truly delivers the “community-driven” piece at scale: you can now add your own tests to the corpus, TestSwarm style."PermalinkCommentsweb browser test google browser-scope internet technical

Where's Walden? » Whole-text DOM functionality and Acid3 redux

2010 Mar 18, 7:15This article describes the largest problem with the Acid3 test: "Acid3 often didn’t test things web authors wanted, but instead it tested things that were broken or not implemented regardless whether anyone truly cared."PermalinkCommentsacid3 web browser html dom test technical

Chromium Blog: Does Your Browser Behave?

2010 Mar 12, 7:56A tool to run Google's ECMA conformance test suite on your browser.PermalinkCommentschrome web browser javascript technical tool test google

Twitter / Mark Pilgrim: Google "rich snippets" add ...

2010 Mar 12, 2:32Google's indexer now examines HTML5 microdata and they provide a tool to test out your pages microdataPermalinkCommentshtml html5 google search microformats metadata rdf technical

Everything you need to know about HTML5 video and audio - Opera Developer Community

2010 Mar 11, 3:39How to do audio & video in the latest version of OperaPermalinkCommentshtml5 html video audio opera web browser technical development reference

Ribbon Hero is the future [dive into mark]

2010 Mar 4, 1:00Its a game-ification link roundup on Dive Into Mark.PermalinkCommentsgame achievement office unit-test foursquare humor

Banksy Pop Up Cinema | LIMITEDHYPE

2010 Mar 3, 2:59'Imagine watching Raging Bull in a dilapidated ring, or Shawshank Redemption in an abandoned prison. That is the concept behind Banksy’s latest stunt, for the UK premiere of his film “Exit Through the Gift Shop“.'
PermalinkCommentsmovie art banksy cultural-disobediance street

Testing the electric vehicle-to-grid connection

2010 Feb 22, 6:30Electric vehicles as components of the future smart electric grid, as roaming batteries providing power as necessary.PermalinkCommentscar electric-vehicle electricity power electric-grid

Unreality - Dolphin Assassins Yield the Greatest Movie Poster and Tagline Ever? |

2010 Feb 3, 6:52"Unwittingly, he trained a dolphin to kill the President of the United States." It sounds like a sentence constructed one word at a time by different people
PermalinkCommentshumor movie dolphin us poster

San Francisco’s Answer to Westboro Baptist Church

2010 Jan 30, 1:23"I Have a Sign" protest sign.
PermalinkCommentssign humor san-francisco

Thought Experiments and Design Principles

2010 Jan 29, 3:54

Raymond Chen has some thought experiments useful for discovering various kinds of stupidity in software design:

Tim Berners-Lee's principles of Web design includes my favorite: Test of Independent Invention. This has a thought experiment containing the construction of the MMM (Multi-Media Mesh) with MRIs (Media Resource Identifiers) and MMTP (Muli-Media Transport Protocol).

The Internet design principles (RFC 1958) includes the Robustness Principle: be strict when sending and tolerant when receiving. A good one, but applied too liberally can lead to interop issues. For instance, consider web browsers. Imagine one browser becomes so popular that web devs create web pages and just test out their pages in this popular browser. They don't ensure their pages conform to standards and accidentally end up depending on the manner in which this popular browser tolerantly accepts non-standard input. This non-standard behavior ends up as de facto standard and future updates to the standard essentially has had decisions made for it.

PermalinkCommentstechnical design principles software development
Older EntriesNewer Entries Creative Commons License Some rights reserved.