Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 800
  • Last Modified:

Javascript in FireFox

This issue is very annoying.  I have a javascript function on my web-site that works fine in Internet Explorer but does not work in FireFox.

Here's the idea behind the script:
 A user wants to view vendors in a different region - they click "Change Regions"
 A flash menu of the state pops up, allowing them to select the region they want.
 The Flash Page links to a page called KickBack.asp which submits a hidden form.
 The form processes and redirects the user to a different home page with their region.

Here's the code on the kickback.asp page:

<%
'From the Flash Pop Up Menu
the_region = Request("reg")

%>
<html>
<head>

<title>RegSend</title>
<script language="javascript">
      function changevalue(flag)
      {
            if (flag==1)
            {
                  window.opener.document.register.w_region.value="1";
                  window.opener.document.register.submit();
            }
            else if (flag==2)
            {
                  window.opener.document.register.w_region.value="2";
                  window.opener.document.register.submit();
            }
            else if (flag==3)
            {
                  window.opener.document.register.w_region.value="3";
                  window.opener.document.register.submit();
            }
            else if (flag==4)
            {
                  window.opener.document.register.w_region.value="4";
                  window.opener.document.register.submit();
            }
            else if (flag==5)
            {
                  window.opener.document.register.w_region.value="5";
                  window.opener.document.register.submit();
            }
            else if (flag==6)
            {
                  window.opener.document.register.w_region.value="6";
                  window.opener.document.register.submit();
            }
            else if (flag==7)
            {
                  window.opener.document.register.w_region.value="7";
                  window.opener.document.register.submit();
            }
      }
</script>
</heaD>


      <body onload="javascript:changevalue(<%=the_region%>)">
      
      
      
      <script language="javascript">
            javascript:window.close()
      </script>
      </body>
</html>
-----------------------
here's the code for the form in question on the home page:

<form name="register" action="reg_change.asp" method="post">
  <input type="hidden" name="w_region" size="24">
</form>
------------------------
Reg_Change.asp simply changes the page using ASP and Response.Redirect, so I don't think the problem is there.

Like I mentioned before, this all works perfect in Internet Explorer - but in FireFox it does not.  Is there anything I'm doing wrong?

An example can be seen at:  http://www.michiganweddingplanner.com (click on "Click Here to Change Your Region")

Thanks for your help!!!
0
steverguy
Asked:
steverguy
  • 3
2 Solutions
 
yasir710Commented:
Hi,

There is some difference in handling of JS by IE and FF. They both have different ways of refering to particular items and that is why your IE code is not working in FF.

I have re-written your kickback.asp page code as:

----------------------------------------------------------
<html>
<head>

<title>RegSend</title>
<script language="javascript">
     function changevalue(flag)
     {
          if (flag==1)
          {
               window.opener.document.register.w_region.value="1";
               window.opener.document.register.submit();
          }
          else if (flag==2)
          {
              // window.opener.document.register.w_region.value="2";
              //window.opener.document.register.submit();
               window.opener.parent.location='reg_change.asp?w_region=2';
                    
          }
          else if (flag==3)
          {
               window.opener.document.register.w_region.value="3";
               window.opener.document.register.submit();
          }
          else if (flag==4)
          {
               window.opener.document.register.w_region.value="4";
               window.opener.document.register.submit();
          }
          else if (flag==5)
          {
               window.opener.document.register.w_region.value="5";
               window.opener.document.register.submit();
          }
          else if (flag==6)
          {
               window.opener.document.register.w_region.value="6";
               window.opener.document.register.submit();
          }
          else if (flag==7)
          {
               window.opener.document.register.w_region.value="7";
               window.opener.document.register.submit();
          }
             
             
            }
            
            function closeMe()
            {
            window.close();
            }
</script>
</head>


     <body onload="closeMe();changevalue(2);">
     </body>
</html>

-----------------------------------------------------------

Note:
For testing purpose, I have used the value '2'.

See the condition where flag==2
   window.opener.parent.location='reg_change.asp?w_region=2';

You need to change the location of the parent page instead of submitting it and also specify the action URL in the location parameter.

Also, now you DON'T  need to add FORM in the home page. You can remove all the code within FORM tag as we have mentioned the action URL and parameter in the popup.

I hope this helps.

Regards
Yasir


0
 
jay_s5Commented:
Take a look at the errors your site is generating in Tools, Error Console in Firefox 2.0 (I think it was Tools, Javascript Console in Firefox 1.5.x) after you have clicked on the "change region" link.

When I tried the link in Firefox 2.0, it didn't work for me, either, and your site generated  a number of errors. Some are innocuous, and a couple weren't. With Firefox, if you have any Javascript errors, your Javascript functions may not work.

I would try fixing them and trying it again.

Although Firefox is much more strict than IE with what you can do with Javascript, redirects are possible.
0
 
yasir710Commented:

I have got this unhandled expception in my FF 1.5.0.8

Error: uncaught exception: [Exception... "Component returned failure code: 0x80004005 (NS_ERROR_FAILURE) [nsIObserverService.removeObserver]"  nsresult: "0x80004005 (NS_ERROR_FAILURE)"  location: "JS frame :: chrome://browser/content/browser.js :: BrowserShutdown :: line 873"  data: no]

As per the following URL, this might have caused by some other element on your page and not caused by the JS used.

http://www.howtocreate.co.uk/emails/CraigStrickland.html


Yasir
0
 
yasir710Commented:

This exception might be caused by closing the FF window onLoad. See the following links:

http://forums.mozillazine.org/viewtopic.php?t=320478
http://weblogs.mozillazine.org/qa/archives/2005/08/need_to_get_som.html
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now