标签出现在IE浏览器中但不是Chrome?

时间:2015-08-14 00:18:02

标签: html vb.net google-chrome

我正在开发一个以小显示大量产品的网站,因此它们都以相同的格式显示。但是,部分产品在Chrome中显示而没有价格,我已在其他浏览器中检查过,问题仅出在Chrome中。

这取自Internet Explorer,并显示产品卡的外观。

enter image description here

这与Chrome中的产品相同:

enter image description here

非常有帮助地显示不在那里的费用。

HTML - 相关标签是lblProductPrice

<div class="index-row">
    <asp:DataList runat="server" ID="dlFeaturedProducts" RepeatColumns="5" RepeatDirection="horizontal" RepeatLayout="Flow" >
        <itemstyle VerticalAlign="top" />
        <itemtemplate>
            <asp:Panel ID="pnlProduct" runat="server" defaultbutton="btnBuy">
                <div class="gallery-product">
                    <div class="gallery-product-image">
                        <asp:HyperLink ID="hlProductImage"  runat="server"><img id="imgProduct" runat="server" /></asp:HyperLink>
                    </div>

                    <div class="gallery-product-details">
                    <div class="gallery-product-freight">
                            <span runat="server" id="divFreeFreight" visible="false"><img src="images/free-delivery.png" alt="Free Shipping On This Item" title="Free Shipping On This Item" /></span>
                        </div>
                        <div class="gallery-product-title">
                            <asp:HyperLink ID="hlProductTitle" runat="server"></asp:HyperLink></strong><asp:Label ID="lblProductID" runat="server" Visible="false"></asp:Label>
                        </div>
                        <div class="gallery-product-price">
                            <asp:Label ID="lblProductPrice" runat="server"></asp:Label> <span class="gallery-product-price-gst">Incl GST</span>
                        </div>
                        <div class="gallery-product-usually">
                            <span id="pnlUsually" runat="server"><asp:Label ID="lblWas" runat="server"></asp:Label><asp:Label ID="lblListPrice" runat="server"></asp:Label></span>&nbsp;
                        </div>

                          <div class="gallery-product-blurb">
                            <asp:Label ID="lblWebBlurb" runat="server"></asp:Label>
                        </div>
                    </div>
                    <input name="hidden" type="hidden" id="UniqueCode" value="" runat="server" />
                    <div class="gallery-buy-bg">
                        <div class="gallery-buy">
                            <asp:TextBox ID="txtQuantity" Text="1" Width="25" MaxLength="4" runat="server" CssClass="textbox" style="text-align:center"></asp:TextBox><br />(quantity)
                        </div>
                        <div class="gallery-buy-button">
                            <div class="grey-button">
                                <asp:LinkButton ID="btnBuy" runat="server" title="Add to Cart" Text="Add to Cart" CommandName="Add" />
                            </div>
                        </div>
                    </div>
                </div>
            </asp:Panel>
        </itemtemplate>
    </asp:DataList>
</div>

VB.Net - 我尝试在if / else语句之前,之后和之后设置lblProductPrice的值,并且对任一浏览器都没有区别。

'Show Product Savings even if discount level on login
            If dr("SELLPRICE9") > 0 And dr("pListPrice") = 0 Then
                If ((dr("SELLPRICE9")) - dr(c.GetPriceLevel())) > ((dr("SELLPRICE1")) - dr(c.GetPriceLevel())) Then
                    'lblProductPrice.Text = "$" + FormatNumber(dr(c.GetPriceLevel()), 2)
                    'lblProductPrice.ForeColor = Drawing.Color.Black
                    lblListPrice.Font.Strikeout = True
                    lblWas.Text = "RRP "
                    lblWas.ForeColor = Drawing.Color.Red
                    lblListPrice.Text = "$" + FormatNumber(dr("SELLPRICE9"), 2)
                    lblListPrice.ForeColor = Drawing.Color.Red
                Else
                    lblWas.Text = ""
                    'lblProductPrice.Text = "$" + FormatNumber(dr(c.GetPriceLevel()), 2)
                    'lblProductPrice.ForeColor = Drawing.Color.Black
                    lblListPrice.Text = ""
                End If

            Else
                If (dr("SELLPRICE1")) > (dr("pListPrice")) Then
                    'lblProductPrice.Text = "$" + FormatNumber(dr(c.GetPriceLevel()), 2)
                Else
                    'lblProductPrice.Text = "$" + FormatNumber(dr(c.GetPriceLevel()), 2)
                    lblWas.Text = "Save $"
                    lblListPrice.Font.Strikeout = False
                    lblListPrice.Text = FormatNumber((dr("pListPrice") - dr(c.GetPriceLevel())), 2)
                    If (dr("pListPrice") - dr(c.GetPriceLevel())) = 0 Then
                        lblListPrice.Visible = False
                        lblWas.Visible = False
                    End If
                End If
                'If lblListPrice.Text <= 0 Then
                '    Dim pnlUsually As HtmlContainerControl = CType(e.Item.FindControl("pnlUsually"), HtmlContainerControl)
                '    pnlUsually.Visible = False
                'End If
            End If
            lblProductPrice.Text = "$" + FormatNumber(dr("SELLPRICE1"), 2)
        End If

客户端HTML - IE

<span valign="top">
            <div id="ContentPlaceHolder1_dlFeaturedProducts_pnlProduct_15" onkeypress="javascript:return WebForm_FireDefaultButton(event, &#39;ContentPlaceHolder1_dlFeaturedProducts_btnBuy_15&#39;)">

                <div class="gallery-product">
                    <div class="gallery-product-image">
                        <a id="ContentPlaceHolder1_dlFeaturedProducts_hlProductImage_15" title="2m HDMI V1.4 Cable" href="Computers/Cables-(Ready-Made)/DVI-HDMI-Cables/Product-Specification-CB30202.aspx"><img src="http://www.globalpc.co.nz/prodimages/CB30201.jpg.axd?maxwidth=165&maxheight=100" id="ContentPlaceHolder1_dlFeaturedProducts_imgProduct_15" alt="2m HDMI V1.4 Cable" border="0" /></a>
                    </div>

                    <div class="gallery-product-details">
                    <div class="gallery-product-freight">

                        </div>
                        <div class="gallery-product-title">
                            <a id="ContentPlaceHolder1_dlFeaturedProducts_hlProductTitle_15" href="Computers/Cables-(Ready-Made)/DVI-HDMI-Cables/Product-Specification-CB30202.aspx">2m HDMI V1.4 Cable</a></strong>
                        </div>
                        <div class="gallery-product-price">
                            <span id="ContentPlaceHolder1_dlFeaturedProducts_lblProductPrice_15">$19.00</span> <span class="gallery-product-price-gst">Incl GST</span>
                        </div>
                        <div class="gallery-product-usually">
                            <span id="ContentPlaceHolder1_dlFeaturedProducts_pnlUsually_15"><span id="ContentPlaceHolder1_dlFeaturedProducts_lblWas_15"></span><span id="ContentPlaceHolder1_dlFeaturedProducts_lblListPrice_15"></span></span>&nbsp;
                        </div>

                          <div class="gallery-product-blurb">
                            <span id="ContentPlaceHolder1_dlFeaturedProducts_lblWebBlurb_15"></span>
                        </div>
                    </div>
                    <input name="ctl00$ContentPlaceHolder1$dlFeaturedProducts$ctl15$UniqueCode" type="hidden" id="ContentPlaceHolder1_dlFeaturedProducts_UniqueCode_15" value="b2cb5ee5-97d4-44a7-99f7-ffa66790ae0c" />
                    <div class="gallery-buy-bg">
                        <div class="gallery-buy">
                            <input name="ctl00$ContentPlaceHolder1$dlFeaturedProducts$ctl15$txtQuantity" type="text" value="1" maxlength="4" id="ContentPlaceHolder1_dlFeaturedProducts_txtQuantity_15" class="textbox" style="width:25px;text-align:center" /><br />(quantity)
                        </div>
                        <div class="gallery-buy-button">
                            <div class="grey-button">
                                <a onclick="if(!isPositiveInteger(document.getElementById(&#39;ContentPlaceHolder1_dlFeaturedProducts_txtQuantity_15&#39;).value)){alert(&#39;Please enter a numeric value for the quantity&#39;);document.getElementById(&#39;ContentPlaceHolder1_dlFeaturedProducts_txtQuantity_15&#39;).select();document.getElementById(&#39;ContentPlaceHolder1_dlFeaturedProducts_txtQuantity_15&#39;).focus();return false;};" id="ContentPlaceHolder1_dlFeaturedProducts_btnBuy_15" title="Add to Cart" href="javascript:__doPostBack(&#39;ctl00$ContentPlaceHolder1$dlFeaturedProducts$ctl15$btnBuy&#39;,&#39;&#39;)">Add to Cart</a>
                            </div>
                        </div>
                    </div>
                </div>

</div>
        </span>

客户端HTML - Chrome

<span valign="top">
                <div id="ContentPlaceHolder1_dlFeaturedProducts_pnlProduct_15" onkeypress="javascript:return WebForm_FireDefaultButton(event, &#39;ContentPlaceHolder1_dlFeaturedProducts_btnBuy_15&#39;)">

                    <div class="gallery-product">
                    <div class="gallery-in-stock">
                        <img id="ContentPlaceHolder1_dlFeaturedProducts_imgStock_15" src="../images/in-stock.png" alt="This item is in stock." />
                    </div>
                        <div class="gallery-product-image">
                            <a id="ContentPlaceHolder1_dlFeaturedProducts_hlProductImage_15" title="2m HDMI V1.4 Cable" href="Cables-(Ready-Made)/DVI-HDMI-Cables/Product-Specification-CB30202.aspx"><img src="http://www.globalpc.co.nz/prodimages/CB30201.jpg.axd?maxwidth=100&maxheight=100" id="ContentPlaceHolder1_dlFeaturedProducts_imgProduct_15" alt="2m HDMI V1.4 Cable" border="0" /></a>
                        </div>
                        <div class="gallery-product-details">
                            <div class="gallery-product-freight">

                            </div>
                            <div class="gallery-product-title">
                                <a id="ContentPlaceHolder1_dlFeaturedProducts_hlProductTitle_15" href="Cables-(Ready-Made)/DVI-HDMI-Cables/Product-Specification-CB30202.aspx">2m HDMI V1.4 Cable</a></strong>
                            </div>
                            <div class="gallery-product-price">
                                <span id="ContentPlaceHolder1_dlFeaturedProducts_lblProductPrice_15"></span> <span class="gallery-product-price-gst">Incl GST</span>
                            </div>
                            <div class="gallery-product-usually">
                                <span id="ContentPlaceHolder1_dlFeaturedProducts_pnlUsually_15"><span id="ContentPlaceHolder1_dlFeaturedProducts_lblWas_15"></span><span id="ContentPlaceHolder1_dlFeaturedProducts_lblListPrice_15"></span></span>&nbsp;
                            </div>

                            <!--<div class="index-product-cash-back">
                                <span id="ContentPlaceHolder1_dlFeaturedProducts_divCashBack_15"><img src="images/cash-back-offer.png" alt="Get CASH back On This Item" title="Get CASH back On This Item" /></span>
                            </div>-->
                            <div class="gallery-product-blurb">
                                <span id="ContentPlaceHolder1_dlFeaturedProducts_lblWebBlurb_15"></span>
                            </div>
                        </div>
                        <input name="ctl00$ContentPlaceHolder1$dlFeaturedProducts$ctl15$ProductID" type="hidden" id="ContentPlaceHolder1_dlFeaturedProducts_ProductID_15" value="CB30202" />
                        <input name="ctl00$ContentPlaceHolder1$dlFeaturedProducts$ctl15$UniqueCode" type="hidden" id="ContentPlaceHolder1_dlFeaturedProducts_UniqueCode_15" value="c9e963b7-4f99-4f1a-8165-28219fae0363" />
                        <div class="gallery-buy-bg">
                            <div class="gallery-buy">
                                <input name="ctl00$ContentPlaceHolder1$dlFeaturedProducts$ctl15$txtQuantity" type="text" value="1" maxlength="4" id="ContentPlaceHolder1_dlFeaturedProducts_txtQuantity_15" class="textbox" style="width:25px;text-align:center" /><br />(quantity)
                            </div>
                            <div class="gallery-buy-button">
                                <div class="grey-button">
                                    <a onclick="if(!isPositiveInteger(document.getElementById(&#39;ContentPlaceHolder1_dlFeaturedProducts_txtQuantity_15&#39;).value)){alert(&#39;Please enter a numeric value for the quantity&#39;);document.getElementById(&#39;ContentPlaceHolder1_dlFeaturedProducts_txtQuantity_15&#39;).select();document.getElementById(&#39;ContentPlaceHolder1_dlFeaturedProducts_txtQuantity_15&#39;).focus();return false;};" id="ContentPlaceHolder1_dlFeaturedProducts_btnBuy_15" AlternateText="Add to Cart" href="javascript:__doPostBack(&#39;ctl00$ContentPlaceHolder1$dlFeaturedProducts$ctl15$btnBuy&#39;,&#39;&#39;)">Add to Cart</a>
                                </div>
                                <input type="submit" name="ctl00$ContentPlaceHolder1$dlFeaturedProducts$ctl15$btnHiddenBuy" value="" id="ContentPlaceHolder1_dlFeaturedProducts_btnHiddenBuy_15" style="display:none;" />
                            </div>
                        </div>
                    </div>

</div>
            </span>

来自Chrome v2的HTML

<div id="ContentPlaceHolder1_dlFeaturedProducts_pnlProduct_1" onkeypress="javascript:return WebForm_FireDefaultButton(event, 'ContentPlaceHolder1_dlFeaturedProducts_btnBuy_1')">

                    <div class="gallery-product">
                    <div class="gallery-in-stock">
                        <img id="ContentPlaceHolder1_dlFeaturedProducts_imgStock_1" src="../images/in-stock.png" alt="This item is in stock.">
                    </div>
                        <div class="gallery-product-image">
                            <a id="ContentPlaceHolder1_dlFeaturedProducts_hlProductImage_1" title="2m HDMI V1.4 Cable" href="Cables-(Ready-Made)/DVI-HDMI-Cables/Product-Specification-CB30202.aspx"><img src="http://www.globalpc.co.nz/prodimages/CB30201.jpg.axd?maxwidth=100&amp;maxheight=100" id="ContentPlaceHolder1_dlFeaturedProducts_imgProduct_1" alt="2m HDMI V1.4 Cable" border="0"></a>
                        </div>
                        <div class="gallery-product-details">
                            <div class="gallery-product-freight">

                            </div>
                            <div class="gallery-product-title">
                                <a id="ContentPlaceHolder1_dlFeaturedProducts_hlProductTitle_1" href="Cables-(Ready-Made)/DVI-HDMI-Cables/Product-Specification-CB30202.aspx">2m HDMI V1.4 Cable</a>
                            </div>
                            <div class="gallery-product-price">
                                <span id="ContentPlaceHolder1_dlFeaturedProducts_lblProductPrice_1"></span> <span class="gallery-product-price-gst">Incl GST</span>
                            </div>
                            <div class="gallery-product-usually">
                                <span id="ContentPlaceHolder1_dlFeaturedProducts_pnlUsually_1"><span id="ContentPlaceHolder1_dlFeaturedProducts_lblWas_1"></span><span id="ContentPlaceHolder1_dlFeaturedProducts_lblListPrice_1"></span></span>&nbsp;
                            </div>

                            <!--<div class="index-product-cash-back">
                                <span id="ContentPlaceHolder1_dlFeaturedProducts_divCashBack_1"><img src="images/cash-back-offer.png" alt="Get CASH back On This Item" title="Get CASH back On This Item" /></span>
                            </div>-->
                            <div class="gallery-product-blurb">
                                <span id="ContentPlaceHolder1_dlFeaturedProducts_lblWebBlurb_1"></span>
                            </div>
                        </div>
                        <input name="ctl00$ContentPlaceHolder1$dlFeaturedProducts$ctl01$ProductID" type="hidden" id="ContentPlaceHolder1_dlFeaturedProducts_ProductID_1" value="CB30202">
                        <input name="ctl00$ContentPlaceHolder1$dlFeaturedProducts$ctl01$UniqueCode" type="hidden" id="ContentPlaceHolder1_dlFeaturedProducts_UniqueCode_1" value="bdf06fb2-74fe-4848-b648-fce81e25c25c">
                        <div class="gallery-buy-bg">
                            <div class="gallery-buy">
                                <input name="ctl00$ContentPlaceHolder1$dlFeaturedProducts$ctl01$txtQuantity" type="text" value="1" maxlength="4" id="ContentPlaceHolder1_dlFeaturedProducts_txtQuantity_1" class="textbox" style="width:25px;text-align:center"><br>(quantity)
                            </div>
                            <div class="gallery-buy-button">
                                <div class="grey-button">
                                    <a onclick="if(!isPositiveInteger(document.getElementById('ContentPlaceHolder1_dlFeaturedProducts_txtQuantity_1').value)){alert('Please enter a numeric value for the quantity');document.getElementById('ContentPlaceHolder1_dlFeaturedProducts_txtQuantity_1').select();document.getElementById('ContentPlaceHolder1_dlFeaturedProducts_txtQuantity_1').focus();return false;};" id="ContentPlaceHolder1_dlFeaturedProducts_btnBuy_1" alternatetext="Add to Cart" href="javascript:__doPostBack('ctl00$ContentPlaceHolder1$dlFeaturedProducts$ctl01$btnBuy','')">Add to Cart</a>
                                </div>
                                <input type="submit" name="ctl00$ContentPlaceHolder1$dlFeaturedProducts$ctl01$btnHiddenBuy" value="" id="ContentPlaceHolder1_dlFeaturedProducts_btnHiddenBuy_1" style="display:none;">
                            </div>
                        </div>
                    </div>

</div>

来自IE v2的HTML

<span valign="top">
            <div id="ContentPlaceHolder1_dlFeaturedProducts_pnlProduct_15" onkeypress="javascript:return WebForm_FireDefaultButton(event, 'ContentPlaceHolder1_dlFeaturedProducts_btnBuy_15')">

                <div class="gallery-product">
                    <div class="gallery-product-image">
                        <a title="2m HDMI V1.4 Cable" id="ContentPlaceHolder1_dlFeaturedProducts_hlProductImage_15" href="Computers/Cables-(Ready-Made)/DVI-HDMI-Cables/Product-Specification-CB30202.aspx"><img id="ContentPlaceHolder1_dlFeaturedProducts_imgProduct_15" alt="2m HDMI V1.4 Cable" src="http://www.globalpc.co.nz/prodimages/CB30201.jpg.axd?maxwidth=165&amp;maxheight=100" border="0"></a>
                    </div>

                    <div class="gallery-product-details">
                    <div class="gallery-product-freight">

                        </div>
                        <div class="gallery-product-title">
                            <a id="ContentPlaceHolder1_dlFeaturedProducts_hlProductTitle_15" href="Computers/Cables-(Ready-Made)/DVI-HDMI-Cables/Product-Specification-CB30202.aspx">2m HDMI V1.4 Cable</a>
                        </div>
                        <div class="gallery-product-price">
                            <span id="ContentPlaceHolder1_dlFeaturedProducts_lblProductPrice_15">$19.00</span> <span class="gallery-product-price-gst">Incl GST</span>
                        </div>
                        <div class="gallery-product-usually">
                            <span id="ContentPlaceHolder1_dlFeaturedProducts_pnlUsually_15"><span id="ContentPlaceHolder1_dlFeaturedProducts_lblWas_15"></span><span id="ContentPlaceHolder1_dlFeaturedProducts_lblListPrice_15"></span></span>&nbsp;
                        </div>

                          <div class="gallery-product-blurb">
                            <span id="ContentPlaceHolder1_dlFeaturedProducts_lblWebBlurb_15"></span>
                        </div>
                    </div>
                    <input name="ctl00$ContentPlaceHolder1$dlFeaturedProducts$ctl15$UniqueCode" id="ContentPlaceHolder1_dlFeaturedProducts_UniqueCode_15" type="hidden" value="b2cb5ee5-97d4-44a7-99f7-ffa66790ae0c">
                    <div class="gallery-buy-bg">
                        <div class="gallery-buy">
                            <input name="ctl00$ContentPlaceHolder1$dlFeaturedProducts$ctl15$txtQuantity" class="textbox" id="ContentPlaceHolder1_dlFeaturedProducts_txtQuantity_15" style="width: 25px; text-align: center;" type="text" maxlength="4" value="1"><br>(quantity)
                        </div>
                        <div class="gallery-buy-button">
                            <div class="grey-button">
                                <a title="Add to Cart" id="ContentPlaceHolder1_dlFeaturedProducts_btnBuy_15" onclick="if(!isPositiveInteger(document.getElementById('ContentPlaceHolder1_dlFeaturedProducts_txtQuantity_15').value)){alert('Please enter a numeric value for the quantity');document.getElementById('ContentPlaceHolder1_dlFeaturedProducts_txtQuantity_15').select();document.getElementById('ContentPlaceHolder1_dlFeaturedProducts_txtQuantity_15').focus();return false;};" href="javascript:__doPostBack('ctl00$ContentPlaceHolder1$dlFeaturedProducts$ctl15$btnBuy','')">Add to Cart</a>
                            </div>
                        </div>
                    </div>
                </div>

</div>
        </span>

修改

有问题的页面是我们的目标网页,它显示了大约30种产品的随机排序选择(来自我老板不久前生成的SQL表格)。

以下是两种产品:

enter image description here

令我困惑的是,这两款产品几乎都显示了相同的字段。两者都有instock tick,free delivery splotch和下面的exta信息标签。但是有价格而另一方没有价格。这可能是服务器方面的问题吗?有问题的项目在每个其他页面上都能正确显示。

1 个答案:

答案 0 :(得分:1)

这是一个猜测,但我仔细查看了HTML中的标记,并且</strong>超链接后面只有一个hlProductTitle标记:

<div class="gallery-product-title">
    <a id="ContentPlaceHolder1_dlFeaturedProducts_hlProductTitle_15" href="Computers/Cables-(Ready-Made)/DVI-HDMI-Cables/Product-Specification-CB30202.aspx">2m HDMI V1.4 Cable</a>
    </strong> <!-- <<<== HERE IT IS (I added the newline before it)
</div>

由于没有匹配的开放<strong>标记,浏览器会尝试通过为您添加一个来“修复”此问题,并尽可能地猜测它应该去哪里。不同的浏览器会做出不同的猜测,这可能会说明您看到差异的原因。支持我的理论的证据(以及下次的线索)是,在IE的截图中,产品标题是粗体,而在Chrome屏幕截图中则不是。我相信,IE的意思是决定在产品标题之前加上开头<strong>标签,而Chrome正在把它放在好的地方。

尝试在产品标题标记之前添加匹配的<strong>标记,看看是否能解决您的问题。