Pub Finder

I’ve got my Google Maps / Beer In The Evening mashup working again. Seems I completely missed the Google Maps API V2 changes which broke the layout and the ‘link to this pub’ links. Unfortunately I still can’t get my CSS to expand the map to the available screen size so if anyone has any suggestions, please leave a comment!

Advertisements

Port scanning in Javascript

This is interesting, a port scanner written completely in Javascript. It creates a series of image objects and points the URL to an image file which would be found on a default installation of some web servers. Once found, the script could be modified to do something malicious to that webserver using any well known exploit.

Obviously, most production servers would be secured so won’t have this default file, however development servers might not be so secure.

The problem is that this isn’t something that can be secured against easily as so many websites use late-loading images by Javascript. The only solution I guess would be to prevent the types of files that the image could point at, but that would break lots of apps.

So until something changes, secure all your servers. [found via New Scientist]

Popups that resize themselves

In your ASPX page, add the following such that it renders in the top-right of the popup window

And add this code such that it renders in the bottom-left of the popup window

Then add the following Javascript to your page and make a call to resizeThisWindow().

// Default window dimensions to add to the size we 'read' from the divs var _modifyX = 18; var _modifyY = 30;  function resizeThisWindow() {   var divX = document.all['divMarkerX'];   var divY = document.all['divMarkerY'];    var x = getAbsX(divX);   var y = getAbsY(divY);    //stop it becoming too big, for little monitor support   if ( x > 800 ) {     x = 800;   }    if ( y > 600 ) {     y = 600;   }      window.resizeTo(x + _modifyX, y + _modifyY);   //alert(x +" " + y); }   function getAbsX(elt) {   return parseInt(elt.x) ? elt.x : getAbsPos(elt,"Left"); }   function getAbsY(elt) {   return parseInt(elt.y) ? elt.y : getAbsPos(elt,"Top"); }   function getAbsPos(elt,which) {   iPos = 0;   while (elt != null) {     iPos += elt["offset" + which];     elt = elt.offsetParent;   }   return iPos; }

The modify X and Y values take into account default window scrollbar widths etc therefore users with non-standard settings may see things differently.

If you use master pages, put the above into a seperate template for popup windows and override the default X and Y in the implementation pages if they use scrollbars etc.

The Enter button in ASP.NET

Taken from this blog is a technique which will postback the form when you hit enter. If you use the script below, it will work in any browser (although bypassing any onClick code for the button specified).

[javascript]
function clickButton(e, buttonid)
{
var bt = document.getElementById(buttonid);
if (typeof bt == ‘object’)
{
try
{
if(navigator.appName.indexOf(“Netscape”)>(-1))
{
if (e.keyCode == 13)
{
bt.click();
return false;
}
}
if (navigator.appName.indexOf(“Microsoft Internet Explorer”)>(-1))
{
if (event.keyCode == 13)
{
bt.click();
return false;
}
}
}
catch (er)
{
// invoke the default postback handler for buttons that render as tags
__doPostBack(buttonid,”);
}
}
}
[/javascript]

External javascript reference

This will link to an external Javascript file. You need the charset attribute if your external file is using international symbols (e.g. £ or $). Also, don’t use inline regular expressions (var rex = /foo/gi;) instead use proper object definitions (var rex = new RegExp(“foo”, “gi”);)

<script charset=”ISO-8859-1″ type=”text/javascript” xsrc=”/money.js” mce_src=”/money.js”></script>