Problem with Opera and JavaScript

S

Shaun Fleming

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="javascript:refreshParentWizard(window,
parent.opener.location);">

It calls refreshParentWizard(), 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 refreshParentWizard(window, location) {

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

if (iQueryString > -1) {
location.href=location.href.substring(0, iQueryString) +
"?action=quicksave&screen=previous_education&";
}
else {
location.href=location +
"action=quicksave&screen=previous_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
 
M

Martin Honnen

Shaun said:
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="javascript:refreshParentWizard(window,
parent.opener.location);">

It calls refreshParentWizard(), 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 refreshParentWizard(window, location) {

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

if (iQueryString > -1) {
location.href=location.href.substring(0, iQueryString) +
"?action=quicksave&screen=previous_education&";
}
else {
location.href=location +
"action=quicksave&screen=previous_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.

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.
 
B

Brynn

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


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="javascript:refreshParentWizard(window,
parent.opener.location);">

It calls refreshParentWizard(), 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 refreshParentWizard(window, location) {

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

if (iQueryString > -1) {
location.href=location.href.substring(0, iQueryString) +
"?action=quicksave&screen=previous_education&";
}
else {
location.href=location +
"action=quicksave&screen=previous_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

Brynn
www.coolpier.com

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!
 
C

Chris Riesbeck

if (iQueryString > -1) {
location.href=location.href.substring(0, iQueryString) +
"?action=quicksave&screen=previous_education&";
}
else {
location.href=location +
"action=quicksave&screen=previous_education&";
}

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

Shaun Fleming

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

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

Shaun
 
S

Shaun Fleming

Martin Honnen said:
Shaun said:
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="javascript:refreshParentWizard(window,
parent.opener.location);">

It calls refreshParentWizard(), 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 refreshParentWizard(window, location) {

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

if (iQueryString > -1) {
location.href=location.href.substring(0, iQueryString) +
"?action=quicksave&screen=previous_education&";
}
else {
location.href=location +
"action=quicksave&screen=previous_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.

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.

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">https://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.
 
S

Shaun Fleming

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="javascript:window.close()" 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
 

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

Members online

No members online now.

Forum statistics

Threads
473,766
Messages
2,569,569
Members
45,042
Latest member
icassiem

Latest Threads

Top