Tech Off Thread

4 posts

Forum Read Only

This forum has been made read only by the site admins. No new threads or comments can be added.

When javascript opens child window fonts change in the parent window

Back to Forum: Tech Off
  • User profile image
    qwert231

    We have a form that has a child window. This child window writes to 4 or 5 hidden inputs via javascript right before closing. None of the values have anything to do with fons or CSS/Styles. However, when we press the button to open the window (no other post back does this) the fonts get bigger.

    The button that is causing this issue is in a User Control.

    Here is what the button does:

    Private Sub btnCrop_Click(ByVal sender As Object, ByVal e As EventArgs) Handles btnCrop.Click
     
    Dim subj As String
     Try
      If Me.tbSubj.Text <> "" Then
       subj = Me.tbSubj.Text
      Else
       If Me.lbSubj.SelectedIndex >= 0 Then subj = Me.lbSubj.SelectedItem.Text
      End If
      If IsNothing(subj) Then Exit Sub
      Session("SubjectID") = subj
      Dim urlStr As New System.Text.StringBuilder
      If Me.useDP2 Then
       'DP2 Image
       Dim subjRow As DataRow = Me.dsPhotos.Tables(0).Rows.Find(subj)
       urlStr.Append(
    "../ImageServices/CropImage.aspx?CartID=" & Me.cartId & "&PhotoID=" & subj & "&CropRatio=" & cropRatio & "&CropOrient=" & cropOrient & "&Order=" & CType(Me.imageOrderNum, String).PadLeft(6, "0") & "&Roll=" & CType(subjRow("Roll"), String).Trim & _
    "&Frame=" & CType(subjRow("Frame"), String).Trim)
      Else
       urlStr.Append("../ImageServices/CropImage.aspx?CartID=" & Me.cartId & "&PhotoID=" & subj & "&CropRatio=" & cropRatio & "&CropOrient=" & cropOrient & "&filePath=" & Me.folder.Replace("\", "|") & "|" & Me.lbSubj.SelectedItem.Text)
      End If
      If Me.cropChoices = True Then urlStr.Append("&cropsVisible=Yes")
      urlStr.Append(
    Me.cropCtrlNames)
      Dim windowstr As New System.Text.StringBuilder
      windowstr.Append(
    "<script>var urlstr = '" & urlStr.ToString & "';" & Chr(10))
      windowstr.Append(
    "msgWindow = open(urlstr,'CropWindow','width=680,height=690,resizable=yes');" & Chr(10))
      windowstr.Append(
    "msgWindow.opener = self;" & Chr(10))
      windowstr.Append(
    "</script>")
      Response.Write(windowstr.ToString)
     Catch ex As Exception
      wFuncs.ReportError(ex,
    "ImageServices - imageSelect", MyVersion, 0, "btnCrop_Click", Me.cartId)
      Me.errs.Text += "There was an error.<br>"
     End Try
    End Sub

  • User profile image
    Sven Groot

    qwert231 wrote:
      Response.Write(windowstr.ToString)

    There's your culprit. When you use Response.Write in a code-behind method, it adds the text all the way at the beginning of the page. This means it puts it before the DOCTYPE line. Any text before the DOCTYPE causes IE6 to use quirks mode instead of standards mode, and the default font size is bigger in quirks mode.

  • User profile image
    qwert231

    You're right... I think. Haven't tested, but I'll just pass the script string to a label... that way it'll be after the DOCType... Thanks.

    lblScript.Text = windowstr.ToString

  • User profile image
    W3bbo

    qwert231 wrote:
    You're right... I think. Haven't tested, but I'll just pass the script string to a label... that way it'll be after the DOCType... Thanks.

    lblScript.Text = windowstr.ToString


    Pass it to a Literal, Labels automatically HtmlEncode

Conversation locked

This conversation has been locked by the site admins. No new comments can be made.