Avoid form redirection on 204 response in ios browsers

泪湿孤枕 提交于 2021-02-07 08:16:05

问题


I have created a form in hubspot.

In IOS devices like iPhone and iPad after successful post of form with the HTTP 204 response, page is redirected to action url, but in windows and android it remains in same page.

Is there any way we can avoid form redirection in iPhone/iPad?


回答1:


I had the same issue, and found no info regarding how to solve it for iOS devices (any browser).

So I've inserted a jquery to scroll down when the url parameters have the string submissionGuid - parameter present in all hubspot form submissions.

  1. Add an ID or Class to the section where you display your inline message. i.e. id="AREA_INLINE_MSG"

  2. Insert the following code when the page is ready:


if (window.location.toString().indexOf("submissionGuid") != -1) {
    $("html, body").animate({
        scrollTop: $("#AREA_INLINE_MSG").offset().top + 3000
    }, 1000);
}

Note: I've added 3000 pixels to the window position to scroll down a little bit more.



来源:https://stackoverflow.com/questions/31454421/avoid-form-redirection-on-204-response-in-ios-browsers

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!