Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Javascript with Firefox

Status
Not open for further replies.

matheusporto

Programmer
Feb 22, 2012
3
BR
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 = ""['Form1'].target=""_blank"";document.forms['Form1'].submit();</script>")

'Response.Write("<script>window.location = ""Aviso.aspx?resultado=Sucesso""</script>")
 
Hi
[ul]
[li]Does the [tt]form[/tt] exist in the moment of executing the JavaScript code ? I mean, where is that JavaScript code placed in the document ?[/li]
[li]Is popup blocking enabled in FireFox ? Maybe you should add an [tt]iframe[/tt] to the page and set that as [tt]target[/tt] instead of [tt]_blank[/tt].[/li]
[/ul]
Next time please post your code between [tt][ignore]
Code:
[/ignore][/tt] and [tt][ignore]
[/ignore][/tt] TGML tags.

Feherke.
 
Thanks for the answer and I apologize about the messy code.

Ok. First of all the Javascript is executed when the user click on a "Confirm" button, so the form already exist at this point.
And yes, i disabled the popup blocking at Firefox configurations.

Well, i'm not highly familiar with the iframe tag but i believe it does not fit with what i want. I need that test.com.br open in a new window or tab, 'cause at the same moment i'll redirect the main window to aviso.aspx.

I would like to remember u guys that it works fine on Internet Explorer.
 
Hi

Ok, then forget the [tt]iframe[/tt] thing. ( No idea why I had a feeling that the POST result will be ignored anyway. )

But this sentence sounds abit strange :
matheusporto said:
First of all the Javascript is executed when the user click on a "Confirm" button, so the form already exist at this point.
Code executed when an event occurs should be inside a function declaration, or in a HTML tag's on-something attribute, in this case [tt]onclick[/tt].

Could you show the part from where that code is executed ?

Feherke.
 
I mean, when the user click on "Confirm" button it means that he already filled the form which i'm 'posting'. It exists.
And the code is placed in a C#(CodeBehind) function which handles click-on events at my "Confirm" button.

Code:
Private Sub LinkButton1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles LinkButton1.Click


If (cbCondicaoPgto.SelectedValue = 18) Then

Response.Write("<script>document.forms['Form1'].method =""post"";document.forms['Form1'].action = ""[URL unfurl="true"]http://www.test.com.br/loja/index.asp"";document.forms[/URL]['Form1'].target=""_blank"";document.forms['Form1'].submit();</script>")
Response.Write("<script>window.location =""Aviso.aspx?resultado=Sucesso""</script>")

Else Response.Redirect("Aviso.aspx?resultado=Sucesso")
 
Hi

Let us stay with the client-side.

How the HTML and JavaScript generated for that [tt]form[/tt] looks ?

Is AJAX involved ? If yes, how a request and a response looks ?

An URL to a publicly accessible version of that page would be the best aid for debugging.

Feherke.
 
I'm pretty sure that the reason it works in Internet Explorer but not in Firefox is because Internet Explorer allows cross-sight scripting while Firefox does not.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top