Blog Stats
  • Posts - 5
  • Articles - 0
  • Comments - 9
  • Trackbacks - 0

 

Tuesday, August 21, 2007

parentNode vs ParentElement javascript.

I realize the following won't have many working examples.  If someone would like a working example of what the heck I'm talking about. Feel free to ask, and I'll create a few.

In the application I'm working on, I had a situation where I wanted to show/hide a div tag to conserve screen real estate.  Pretty simple to do.  However, using CSS with relative positioning I quickly ran into problems with the section being shown overlapping frames and objects beneath it.  I needed to increase the size of the parent container in order order to make sure that the newly shown div didn't overlap objects beneath it.

After some quick experimentation I found begin simply setting the obj.parentElement.style.height property.  Everthing seemed fine in my javascript.  So today I'm playing around with what I've done in production when I find that when I click the button to open the div tag, it would do a postback.  After some quick legwork I found that in firefox parentElement doesn't evalutate.  Some quick searching on the internet found that the preferred method was to use parentNode instead.  This seemed to also work with Internet Explorer.  Changing it to use parentNode worked great.


A firefox tool that really made it easier to work with this problem is Firebug.  It allows you to breakpoint javascript and inspect errors and variables.
https://addons.mozilla.org/en-US/firefox/addon/1843

Thursday, August 16, 2007

App_Browsers browser .config file for the Palm

I was having troubles a month ago with .net reporting the Treo 650 Blazer browser as not being mobile.   After a little research I thought the app_browsers and the brower.config files were going to be a good send.  If you haven't worked with browser.config files, you can basically define the user agent string you want to match on and set how you want the properties to return.  For instance, in my case the blazer browser from the palm was not returning as a mobile device.  So I could change how the browser is evaluated and make it be a mobile device.

However, I quickly began having troubles recognizing the blazer user agent string and having the browser.config file work for it.  If I changed my agent string to something completely different then I could get a .config file to work correctly.  

I had something like the following.
<browsers>
    <browser id="TreoBlazer" parentID="default">
        <identification>
            <userAgent match="Blazer" />
        </identification>

        <capture>
            <userAgent match="Blazer.(?'version'(?'major'\d+)(?'minor'\.\d+))" />
       </capture>
    </browser>
</browsers>


So if I changed my useragent I was sending to something like 'DOTNET CODER" and changed the user agent match to "DOTNET CODER" it would work perfectly.   I had at that time constructed a browserinfo.aspx web page just to check the values that the browser was reporting. 

Finally I noticed that hte browser was being reported as IE6TO9.  After some playing around with I realized that the parentID has to be the upstream browser that is reported.  I'm not completely sure how it works, but since the browser agent was already being matched in the chain of browsers that was constructed, there was no way it would match with the parent being set to default.

So Changing the parentID to "IE6to9" worked like a charm.  It finally began recognizing the blazer .config file I had created.

My final .config file looks something like the following.  

<browsers>
    <!-- sample UA "Mozilla/2.0 (compatible; Elaine/3.0)" -->
    <!-- sample UA "Mozilla/2.0 (compatible; Elaine/1.0)" -->
    <browser id="TreoBlazer" parentID="IE6to9">
        <identification>
            <userAgent match="Blazer" />
        </identification>

        <capture>
            <userAgent match="Blazer.(?'version'(?'major'\d+)(?'minor'\.\d+))" />
            <userAgent match="16\;(?'screenPixelsHeight'\d+)x(?'screenPixelsWidth'\d+)" />
        </capture>

        <capabilities>
            <capability name="browser"                                 value="Blazer" />
            <capability name="cookies"                                 value="true" />
            <capability name="defaultScreenCharactersHeight"           value="6" />
            <capability name="defaultScreenCharactersWidth"            value="12" />
            <capability name="defaultScreenPixelsHeight"               value="72" />
            <capability name="defaultScreenPixelsWidth"                value="96" />
            <capability name="ecmascriptversion"                       value="1.1" />
            <capability name="frames"                                  value="true" />
            <capability name="gatewayMajorVersion"                     value="${gatewayMajorVersion}" />
            <capability name="gatewayMinorVersion"                     value="${gatewayMinorVersion}" />
            <capability name="gatewayVersion"                          value="${gatewayMajorVersion}${gatewayMinorVersion}" />
            <capability name="hidesRightAlignedMultiselectScrollbars"  value="true" />
            <capability name="inputType"                               value="virtualKeyboard" />
            <capability name="isColor"                                 value="false" />
            <capability name="isMobileDevice"                          value="true" />
            <capability name="javaapplets"                             value="false" />
            <capability name="javascript"                              value="false" />
            <capability name="mobileDeviceManufacturer"                value="PalmOS-licensee" />
            <capability name="majorVersion"                               value="${major}" />
            <capability name="minorVersion"                               value="${minor}" />
            <capability name="screenPixelsHeight"                      value="${screenPixelsHeight}" />
            <capability name="screenPixelsWidth"                       value="${screenPixelsWidth}" />
            <capability name="requiresAdaptiveErrorReporting"          value="true" />
            <capability name="requiredMetaTagNameValue"                value="PalmComputingPlatform" />
            <capability name="requiresHtmlAdaptiveErrorReporting"      value="true" />
            <capability name="screenBitDepth"                          value="2" />
            <capability name="screenCharactersHeight"                  value="12" />
            <capability name="screenCharactersWidth"                   value="36" />
            <capability name="screenPixelsHeight"                      value="160" />
            <capability name="screenPixelsWidth"                       value="160" />
            <capability name="supportsBodyColor"                       value="false" />
            <capability name="supportsBold"                            value="true" />
            <capability name="supportsCss"                             value="false" />
            <capability name="supportsDivNoWrap"                       value="false" />
            <capability name="supportsEmptyStringInCookieValue"        value="false" />
            <capability name="supportsFontColor"                       value="false" />
            <capability name="supportsFontName"                        value="false" />
            <capability name="supportsFontSize"                        value="true" />
            <capability name="supportsItalic"                          value="true" />
            <capability name="supportsImageSubmit"                     value="false" />
            <capability name="tables"                                  value="false" />
            <capability name="type"                                    value="MyPalm" />
            <capability name="vbscript"                                value="false" />
        </capabilities>

        <controlAdapters markupTextWriterType="System.Web.UI.Html32TextWriter">
            <adapter controlType="System.Web.UI.WebControls.Menu"
                     adapterType="System.Web.UI.WebControls.Adapters.MenuAdapter" />
        </controlAdapters>
    </browser>

</browsers>

Wednesday, August 15, 2007

FireFox User Agent

Since I've been developing for mobile devices lately, I've needed to test what the site does based upon what browser is hitting it.

I've found a need to make my web browser report the User Agent from the Blazer browser or any other browser for that matter.  There are quite a few ways to do this.  Luckily a co-worker happened to show me the User Agent plug in for Firefox.

It's called User Agent Switcher and lets you switch out the reported user agent of your firefox browser at will.  Remember, this of course does not emulate how the target emulation browser would render the page, but simply reports that you are using that particular browser to the server.
chrispederick.com/work/user-agent-switcher/

Here are a couple of sample user Agent strings I've found handy.

Treo 650 Palm
Mozilla/4.0 (compatible; MSIE 6.0; Windows 98; PalmSource/hspr-H102; Blazer/4.2) 16;320x320

Treo 700 Windows Mobile
Mozilla/4.0 (compatible; MSIE 4.01; Windows CE; PPC; 240x320)

Tuesday, August 14, 2007

Textbox width not set in Firefox or browsers besides ie.

Currently I'm doing some mobile development.  I've noticed lately when trying to format pages with textboxes that the textbox was ignoring the width property.  The Treo 650P and Treo 650W were both exhibiting this behavior.  Then I realized that firefox also had this happening, I just hadn't really cared that much until I started needing to manage my screen real estate on mobile devices.

I did find a few solutions.  Setting the width with CSS or setting the columns property.

 

eg.

 <asp:TextBox ID="PlayerHandicapValue" runat="server" Width="20" Columns="3"  Text="Textbox Text">
 </asp:TextBox>

 

Sources

 http://weblogs.asp.net/donxml/archive/2003/04/23/5993.aspx

blogs.mit.edu/CS/blogs/dsrobey/archive/2005/04/11/10245.aspx

 

Woot First Post

Next thing you know and I'll be simply posting IBTL

 

This is going to be a bit of an experiment for me.  I mainly only want a blog to record the little problems and workarounds I find that I need to do in C# and asp.net.  I don't imagine that I'll be formatting it very nice, and my grammar and spelling are atrocious.  So enjoy.

I've found so many of the solutions to problems I have on blogs, that I thought it woudl be nice to contribute back.  Even if it is  a pathetic attempt. 

 

 

Copyright © Kendall