• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

submit then redirect to location.href

 
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
i have made this function:

function cll()

{this.document.forms["myform"].submit();
var p=document.getElementById('myLink').href;
location.href =p;
}

it work under firefox but under IE but it's notworking with google chrome
 
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
"abdel abdell", please check your private messages for an important administrative matter. Thanks.
 
author
Posts: 15385
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Um, you are submitting a form and redirecting? Shouldn't the server do the redirection? You basically are creating a race condition here.

Eric

 
abdel solarie
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
teh server should do the redirection,
this is the form <form id="myform" action="urlt0.do" method="post">
<html:hidden name="urlt0" property="url_page_t0" value=""/>
</form>

fro the redirect: this is the link :

<a id="myLink" href="/projet_web/search.do?ml=38&fpc=1000&tpc=66" >
<input type="hidden"/></a>
<input name="button" type="button" class="inputbutton" value="Recherche" onclick="cll()" />
 
Eric Pascarello
author
Posts: 15385
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
UseCodeTags

You can not do both of these actions. You can do one or the other.

 
abdel solarie
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
but it works with firefox et IE why it's not works on chrome ?
 
Eric Pascarello
author
Posts: 15385
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You are submitting the page. It starts to leave the page

It is a coin flip that the next lines of JavaScript runs.

Chrome is doing what it should do. It says the form is submitted, exit the page and stop running more code.

The redirection should be done on the serverside, or you need to redesign how you do the submission. It is as simple as passing the redirect value in a form filed and calling redirect on the server with that value.

If you can not change the form on the server, than you need to look at a different way to submit the form. That would be an Ajax submission.

Eric
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic