form POST in iframe without affecting history

前端 未结 5 873
野的像风
野的像风 2020-12-09 20:27

Is it possible to submit a form inside an iframe without affecting the browser\'s history?

I\'ve implemented sending a cross domain POST request. It uses Javascript

5条回答
  •  南方客
    南方客 (楼主)
    2020-12-09 21:19

    Does it work to use JS to add an IFRAME whose src is hosted at your site (the domain to which the third-party-hosted script needs to send data?) This IFRAME could include the needed Javascript to make an XMLHttpRequest to your/its domain. And as for getting the actual data to this IFRAME from the third-party-site - try: http://softwareas.com/cross-domain-communication-with-iframes . It's a pretty clever solution involving changing fragment identifiers (#something) at the end of the IFRAME URL, which you can then read via JS within the IFRAME.

    Also a guess, but if you tack this past SO solution to a similar history problem (using location.replace) on to the above this hopefully should let you do the anchor-changing part without disrupting the history stack.

提交回复
热议问题