Javascript assistance needed

T

tommcd24

I realize this may not be the ideal place to seek JavaScript
assistance, but I have an ASP.NET webform that has some dynamically
generated JavaScript on it. The JavaScript I have works great in IE,
but I need it to be compatible with Firefox as we have about 12% of
our visitors use that browser. I've posted on some fo the JavaScript
groups, but the fact that I'm dynamically generating the Javascript
seems to confuse users of those groups.

Basically what I have is a webform that collects data. I have a date
field, and next to it a small button that the user can click to open a
new window which displays a calendar view for them to select a date.
The Javascript to display the calendar works great in both IE and
Firefox.

When a user selects a date I then need to "transfer" that value back
to the parent window and then close the calendar window. My issue is
in the Javascript that "transfers" that data back to the parent. I
build the JavaScript in the method below which is called when a date
is clicked on the calendar.

Private Sub Calendar_SelectionChanged(ByVal sender As Object, ByVal e
As System.EventArgs) Handles Calendar.SelectionChanged
Dim strJavaScript As String = _
"<script language='javascript'>window.opener." &
HttpContext.Current.Request.QueryString("formname") & ".value='" &
Calendar.SelectedDate & "';window.close();</script>"

Literal1.Text = strJavaScript

End Sub
 
T

tommcd24

Continuation of first post - accidentally posted before I was done...

The issue seems to be in the piece that ends up translating to
something like this:

window.opener.myDateField.value={DateSelected};

If I remove that piece of code, the window.close does work, and again
all of this works great in IE. Any assistance on how to modify this to
work with Firefox would be greatly appreciated!!!
 
T

tommcd24

Continuation of first post - accidentally posted before I was done...

The issue seems to be in the piece that ends up translating to
something like this:

window.opener.myDateField.value={DateSelected};

If I remove that piece of code, the window.close does work, and again
all of this works great in IE. Any assistance on how to modify this to
work with Firefox would be greatly appreciated!!!

Found the problem. When setting the JavaScript string in
Calendar_SelectionChanged() code window.opener.control works in IE.
However, Firefox needs the more proper window.opener.document.control,
which works in both IE and Firefox.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top