views:

35

answers:

2

Hi, We came across a strange behavior while using html tag. Actually the issue was because of improper usage of the tag. As a result of that, the page was getting submitted 3 times in Mozilla Firefox and 2 times in IE7. Here is the issue.

<link rel="stylesheet" type="text/css" title="Style" href=''/css/image.css'>

This was the code that we were using in one of our J2EE application. When we inspected the request and response (using HTTP Watch), we found out that the page was requested 3 times from the server. We found out that the additional "quote" after href= is causing the problem. We were not able to find out the reason why this was causing multiple page submissions. Is it because, the additional quote makes the href empty and because of that browser tries to load the styleclass from the same URL that loaded the page? Can someone please help to find out the reason why this is happening? Any help will be greatly appreciated.

+1  A: 

this explanation came from this article on Yahoo Developer site. Section Avoid Empty Image src:

When an empty string is encountered as a URI, it is considered a relative URI and is resolved according to the algorithm defined in section 5.2. This specific example, an empty string, is listed in section 5.4.

Although it still not clear whether this behavior affect href or not (the article mainly concerned on empty src). But looks like it does:

Hopefully, browsers will not have this problem in the future. Unfortunately, there is no such clause for <script src=""> and <link href="">. Maybe there is still time to make that adjustment to ensure browsers don't accidentally implement this behavior.

note: I never encounter such behavior so it's just theoretical answer :)

bangbambang
A: 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt;
<html lang="en" xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
    <head>        
    </head>
    <body>
        <table width="100%" cellspacing="0" cellpadding="0" border="0" class="mainOutterTable">
            <tbody>
                <tr>
                    <td>
                        <table class="layoutColumn" cellpadding="0" cellspacing="0">
                            <tr>
                                <td style="width:100%;" valign="top">
                                    <table class="layoutRow" cellpadding="0" cellspacing="0">
                                        <tr>
                                            <td valign="top" width="910">
                                                <table class="layoutColumn" cellpadding="0" cellspacing="0">
                                                    <tr>
                                                        <td style="width:100%;" valign="top">
                                                            <table class="layoutRow" cellpadding="0" cellspacing="0">
                                                                <tr>
                                                                    <td valign="top" width="294">
                                                                        <table class="layoutColumn" cellpadding="0" cellspacing="0">
                                                                            <tr>
                                                                                <td style="width:100%;" valign="top">
                                                                                    <a name="7_N1K8HIC0GOO780I2B1KASD3047"></a>
                                                                                    <div class="wpsPortletBody">
                                                                                        This is a sample textf 3.
                                                                                        <link rel="stylesheet" type="text/css" title="Style" href=''/>
                                                                                    </div>
                                                                                </td>
                                                                            </tr>
                                                                        </table>
                                                                    </td>
                                                                </tr>
                                                            </table>
                                                        </td>
                                                    </tr>
                                                </table>
                                            </td>
                                        </tr>
                                    </table>
                                </td>
                            </tr>
                        </table>
                    </td>
                </tr>
            </tbody>
        </table>
    </body>
</html>

I was able to reproduce the problem on a test page.alt text

This is mentioned in Section 5.2 of http://www.apps.ietf.org/rfc/rfc3986.html#sec-5.2 If the Relative path is empty, then the target URI is the base path. if (R.path == "") then T.path = Base.path;

Jish