Problem with Opera and JavaScript

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Shaun Fleming

    Problem with Opera and JavaScript

    I've been trying to make this simple script compatible across various
    browsers. It works for IE 6.0 and NS 7 but doesnt work with Opera (I
    have version 7.11). This is what is supposed to happen: when the user
    clicks a button in the main window, a dialog window pops up. In the
    dialog the user enters a university to search for. When the string is
    submitted, the dialog then shows all the matches found in the
    database. The user picks one and clicks the Submit button. The Submit
    button's code is as follows:

    <INPUT type="button" value="Submit"
    onclick="javasc ript:refreshPar entWizard(windo w,
    parent.opener.l ocation);">

    It calls refreshParentWi zard(), whose sole purpose is to edit the
    query string arguments so that the main page will save itself when a
    university is returned. Its code is:

    function refreshParentWi zard(window, location) {

    // find the querystring (if it exists)
    iQueryString = location.href.i ndexOf('?');

    if (iQueryString > -1) {
    location.href=l ocation.href.su bstring(0, iQueryString) +
    "?action=quicks ave&screen=prev ious_education& ";
    }
    else {
    location.href=l ocation +
    "action=quicksa ve&screen=previ ous_education&" ;
    }

    document.forms[0].submit();

    self.close();

    return true;

    }

    After the button is clicked, the function is called which submits the
    form and closes the window (as seen in the code above). Then the main
    window is refreshed displaying the University the user picked in a
    field. The problem is Opera will refresh the main page but the
    selected university does not show up. I have tried many different ways
    to do it but none will work. I have checked to make sure that the form
    is passing the right query string arguments when submitted and it is
    passing the same arguments in every browser. I have also checked the
    docs for Opera to see if it supports the functions and it appears that
    it does. I was having problems getting the script to work in NS but I
    got it to work by changing the Submit button type from "submit" to
    "button" and simply calling form.submit(). I am pretty lost so if
    anyone could help me, it would be greatly appreciated.

    Thanks,
    Shaun
  • Martin Honnen

    #2
    Re: Problem with Opera and JavaScript



    Shaun Fleming wrote:
    [color=blue]
    > I've been trying to make this simple script compatible across various
    > browsers. It works for IE 6.0 and NS 7 but doesnt work with Opera (I
    > have version 7.11). This is what is supposed to happen: when the user
    > clicks a button in the main window, a dialog window pops up. In the
    > dialog the user enters a university to search for. When the string is
    > submitted, the dialog then shows all the matches found in the
    > database. The user picks one and clicks the Submit button. The Submit
    > button's code is as follows:
    >
    > <INPUT type="button" value="Submit"
    > onclick="javasc ript:refreshPar entWizard(windo w,
    > parent.opener.l ocation);">
    >
    > It calls refreshParentWi zard(), whose sole purpose is to edit the
    > query string arguments so that the main page will save itself when a
    > university is returned. Its code is:
    >
    > function refreshParentWi zard(window, location) {
    >
    > // find the querystring (if it exists)
    > iQueryString = location.href.i ndexOf('?');
    >
    > if (iQueryString > -1) {
    > location.href=l ocation.href.su bstring(0, iQueryString) +
    > "?action=quicks ave&screen=prev ious_education& ";
    > }
    > else {
    > location.href=l ocation +
    > "action=quicksa ve&screen=previ ous_education&" ;
    > }
    >
    > document.forms[0].submit();
    >
    > self.close();
    >
    > return true;
    >
    > }
    >
    > After the button is clicked, the function is called which submits the
    > form and closes the window (as seen in the code above). Then the main
    > window is refreshed displaying the University the user picked in a
    > field. The problem is Opera will refresh the main page but the
    > selected university does not show up. I have tried many different ways
    > to do it but none will work. I have checked to make sure that the form
    > is passing the right query string arguments when submitted and it is
    > passing the same arguments in every browser. I have also checked the
    > docs for Opera to see if it supports the functions and it appears that
    > it does. I was having problems getting the script to work in NS but I
    > got it to work by changing the Submit button type from "submit" to
    > "button" and simply calling form.submit(). I am pretty lost so if
    > anyone could help me, it would be greatly appreciated.[/color]

    Are you getting any errors in the Opera JavaScript console?

    Although you have provided a long description anyone trying to
    understand what could go wrong will much easier be able to do that if
    you provide a URL to a test page where the problem happens. I understand
    that it might be a problem if server side code is involved that is not
    on a public server but maybe a test case with static pages allows to
    demonstrate the problem.


    --

    Martin Honnen


    Comment

    • Brynn

      #3
      Re: Problem with Opera and JavaScript


      Upgrade to IE ... lol ;) ... jk


      On 21 Jan 2004 08:55:30 -0800, spfjr@mail.umd. edu (Shaun Fleming)
      wrote:
      [color=blue]
      >I've been trying to make this simple script compatible across various
      >browsers. It works for IE 6.0 and NS 7 but doesnt work with Opera (I
      >have version 7.11). This is what is supposed to happen: when the user
      >clicks a button in the main window, a dialog window pops up. In the
      >dialog the user enters a university to search for. When the string is
      >submitted, the dialog then shows all the matches found in the
      >database. The user picks one and clicks the Submit button. The Submit
      >button's code is as follows:
      >
      ><INPUT type="button" value="Submit"
      >onclick="javas cript:refreshPa rentWizard(wind ow,
      >parent.opener. location);">
      >
      >It calls refreshParentWi zard(), whose sole purpose is to edit the
      >query string arguments so that the main page will save itself when a
      >university is returned. Its code is:
      >
      >function refreshParentWi zard(window, location) {
      >
      > // find the querystring (if it exists)
      > iQueryString = location.href.i ndexOf('?');
      >
      > if (iQueryString > -1) {
      > location.href=l ocation.href.su bstring(0, iQueryString) +
      >"?action=quick save&screen=pre vious_education &";
      > }
      > else {
      > location.href=l ocation +
      >"action=quicks ave&screen=prev ious_education& ";
      > }
      >
      > document.forms[0].submit();
      >
      > self.close();
      >
      > return true;
      >
      >}
      >
      >After the button is clicked, the function is called which submits the
      >form and closes the window (as seen in the code above). Then the main
      >window is refreshed displaying the University the user picked in a
      >field. The problem is Opera will refresh the main page but the
      >selected university does not show up. I have tried many different ways
      >to do it but none will work. I have checked to make sure that the form
      >is passing the right query string arguments when submitted and it is
      >passing the same arguments in every browser. I have also checked the
      >docs for Opera to see if it supports the functions and it appears that
      >it does. I was having problems getting the script to work in NS but I
      >got it to work by changing the Submit button type from "submit" to
      >"button" and simply calling form.submit(). I am pretty lost so if
      >anyone could help me, it would be greatly appreciated.
      >
      >Thanks,
      >Shaun[/color]

      Brynn


      I participate in the group to help give examples of code.
      I do not guarantee the effects of any code posted.
      Test all code before use!

      Comment

      • Chris Riesbeck

        #4
        Re: Problem with Opera and JavaScript

        spfjr@mail.umd. edu (Shaun Fleming) wrote in message news:<e9e7e18c. 0401210855.4312 56dc@posting.go ogle.com>...[color=blue]
        >
        > if (iQueryString > -1) {
        > location.href=l ocation.href.su bstring(0, iQueryString) +
        > "?action=quicks ave&screen=prev ious_education& ";
        > }
        > else {
        > location.href=l ocation +
        > "action=quicksa ve&screen=previ ous_education&" ;
        > }[/color]

        don't you want "?action=.. ." here?

        Comment

        • Shaun Fleming

          #5
          Re: Problem with Opera and JavaScript

          riesbeck@cs.nor thwestern.edu (Chris Riesbeck) wrote in message news:<b7acf703. 0401221121.453e 2fd6@posting.go ogle.com>...[color=blue]
          > spfjr@mail.umd. edu (Shaun Fleming) wrote in message news:<e9e7e18c. 0401210855.4312 56dc@posting.go ogle.com>...[color=green]
          > >
          > > if (iQueryString > -1) {
          > > location.href=l ocation.href.su bstring(0, iQueryString) +
          > > "?action=quicks ave&screen=prev ious_education& ";
          > > }
          > > else {
          > > location.href=l ocation +
          > > "action=quicksa ve&screen=previ ous_education&" ;
          > > }[/color]
          >
          > don't you want "?action=.. ." here?[/color]

          Yea it is "?action=.. ." in the actual code. I mustve somehow deleted
          the question mark when pasting the code. Sorry.

          Shaun

          Comment

          • Shaun Fleming

            #6
            Re: Problem with Opera and JavaScript

            Martin Honnen <mahotrash@yaho o.de> wrote in message news:<400fba47$ 1@olaf.komtel.n et>...[color=blue]
            > Shaun Fleming wrote:
            >[color=green]
            > > I've been trying to make this simple script compatible across various
            > > browsers. It works for IE 6.0 and NS 7 but doesnt work with Opera (I
            > > have version 7.11). This is what is supposed to happen: when the user
            > > clicks a button in the main window, a dialog window pops up. In the
            > > dialog the user enters a university to search for. When the string is
            > > submitted, the dialog then shows all the matches found in the
            > > database. The user picks one and clicks the Submit button. The Submit
            > > button's code is as follows:
            > >
            > > <INPUT type="button" value="Submit"
            > > onclick="javasc ript:refreshPar entWizard(windo w,
            > > parent.opener.l ocation);">
            > >
            > > It calls refreshParentWi zard(), whose sole purpose is to edit the
            > > query string arguments so that the main page will save itself when a
            > > university is returned. Its code is:
            > >
            > > function refreshParentWi zard(window, location) {
            > >
            > > // find the querystring (if it exists)
            > > iQueryString = location.href.i ndexOf('?');
            > >
            > > if (iQueryString > -1) {
            > > location.href=l ocation.href.su bstring(0, iQueryString) +
            > > "?action=quicks ave&screen=prev ious_education& ";
            > > }
            > > else {
            > > location.href=l ocation +
            > > "action=quicksa ve&screen=previ ous_education&" ;
            > > }
            > >
            > > document.forms[0].submit();
            > >
            > > self.close();
            > >
            > > return true;
            > >
            > > }
            > >
            > > After the button is clicked, the function is called which submits the
            > > form and closes the window (as seen in the code above). Then the main
            > > window is refreshed displaying the University the user picked in a
            > > field. The problem is Opera will refresh the main page but the
            > > selected university does not show up. I have tried many different ways
            > > to do it but none will work. I have checked to make sure that the form
            > > is passing the right query string arguments when submitted and it is
            > > passing the same arguments in every browser. I have also checked the
            > > docs for Opera to see if it supports the functions and it appears that
            > > it does. I was having problems getting the script to work in NS but I
            > > got it to work by changing the Submit button type from "submit" to
            > > "button" and simply calling form.submit(). I am pretty lost so if
            > > anyone could help me, it would be greatly appreciated.[/color]
            >
            > Are you getting any errors in the Opera JavaScript console?
            >
            > Although you have provided a long description anyone trying to
            > understand what could go wrong will much easier be able to do that if
            > you provide a URL to a test page where the problem happens. I understand
            > that it might be a problem if server side code is involved that is not
            > on a public server but maybe a test case with static pages allows to
            > demonstrate the problem.[/color]

            Sorry for the delay in response. I had to ask my boss if it was ok to
            post the site. And No I am not getting any errors in the Javascript
            console. I am currently looking at another thread where another guy
            had a similar problem as me with Opera 7 (I think the thread is called
            "Javascript and Opera 7" or something along those lines). The link to
            the site is <a href="https://was-1.umd.edu/admissions/Entry.jsp">http s://was-1.umd.edu/admissions/Entry.jsp</a>
            but u will need to fill out some registration stuff bc this web app is
            currently being used for graduate applications. Once you've filled out
            everything and returned the confirmation email, the problem is when
            you click the Previous Education tab and click the magnifying glass
            next to the "College/University" text field. Another window will then
            pop up where you will have to enter a search string for a college
            name. Once you submit the search a list of matches will come up.
            Select one and click submit. The dialog window will close and the main
            page will be refreshed but instead of having the text field next to
            the magnifying glass, you should see a bullet and the college you
            picked. However, this doesnt work in Opera (the form does not seem to
            be submitted for some reason). If you want to see how it should work,
            do the steps above in IE or Netscape 7. And again, any suggestions
            would be greatly appreciated.

            Thanks,
            Shaun

            P.S. You might not want to actually submit the entire application
            because this site is a prod site and all applications do get looked at
            by the University.

            Comment

            • Shaun Fleming

              #7
              Re: Problem with Opera and JavaScript

              Hi,
              I solved my problem yesterday. After looking at many threads in this
              newsgroup, I was getting the impression that many other people were
              having a problem submitting a form in Opera via the form.sumbit()
              function. I experimented with the code and realized that Opera does
              not submit the form when the form.submit() function is called.
              However, there is no error in the JavaScript console. I tried changing
              the input type of the Submit button from "button" to "submit" (I was
              using an ordinary button that, when clicked, called a function to
              submit the form, refresh the main page, and close the current child
              window in which the form was located. I did this because I was having
              some problems using an input of type "submit" in Netscape.) Upon
              changing the type of the button to "submit", the form was properly
              submitted but I could not close the child window which it was in
              because it would either close the window before the form was submitted
              or it would submit the form and load a white screen before the close()
              function could be called. The solution to this (at least the only one
              I could think of that would work in my particular situation) is to put
              "onunload="java script:window.c lose()" in the body tag. Even though it
              seems redundant, in that one would figure that this would be called
              when the window was being closed and as a result be in the process of
              unloading, it works because this is called after the form has been
              submitted but before the next page (the white screen resulting from
              the submission) was loaded. After testing it with under various
              circumstances (i.e. Opera's spoofing ability and other variations),
              the modification seems to work in all cases. Thanks to all who took
              the time to read and try to help me out.

              Shaun Fleming

              Comment

              Working...