www.webdeveloper.com
Results 1 to 2 of 2

Thread: Javascript with Firefox

  1. #1
    Join Date
    Feb 2012
    Posts
    1

    Javascript with Firefox

    Hi everybody..

    I'm trying to do a post in my asp page through a Javascript statement. It works fine when i use IE, but with Firefox it doesn't. I've to make it works for both browsers. Any idea?

    Thanks.


    Here's the code i'm using.

    Response.Write("<script>document.forms['Form1'].method = ""post"";document.forms['Form1'].action = ""http://www.test.com.br/loja/index.asp"";document.forms['Form1'].target=""_blank"";document.forms['Form1'].submit();</script>")

    'Response.Write("<script>window.location = ""Aviso.aspx?resultado=Sucesso""</script>")

  2. #2
    Join Date
    Dec 2002
    Location
    St. Louis, MO, USA
    Posts
    1,582
    IE has this annoying thing called "quirks mode", where it attempts to guess what the developer had in mind when writing the code, but the code isn't correct. In this case, IE guessed right, so that's why it works in IE but not FF (nor, I guess, would it work in Safari, Opera, Konqueror, etc.)

    Firstly, you have quoting issues. While "" works within a string in ASP and ColdFusion, JavaScript doesn't understand. You'd have to escape a single " with a backslash \.

    Also, the beginning and ending of the string should be defined by one kind of quote (' or "), while parameters inside should be marked using whichever isn't used to start/end the string (ie, "This is the 'beginning' of the string" or 'This is the "end" of the string').

    Yet another issue is - you are trying to place a <script> inside a <script>, and <script> tags don't nest. Well, not very well, anyway. You could jam that square peg into the round hole, but it would be a lot of work, and just not worth doing, IMHO.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles