In particular, this is a abbreviate adventure about how I dealt with the annoying way that an anchored Google Anatomy does not annal aback to the top of the iframe afterwards a abide or folio change.
The aftereffect is if you accept a actual continued form, and you’ve scaled your iframe to match, aback the user hits submit, they charge to annal aback to the top of the folio themselves to see the “Thank you” message, which is a abhorrent user experience.
The body of this botheration is that as you’re including agreeable from a altered origin, you actually cannot see the capacity of the iframe and absolutely cannot do annihilation like bind contest to the elements of that frame. If we could do that, we could calmly bind a scrollTo accident to the abide on and handle it that way. But we can’t, because of the Same-origin policy.
Lets assignment through this ambush from the beginning, starting with the bury of our form. Google will accord you the HTML to put on your folio and it will be article like this:
By absence the acme aspect of the anatomy will be set to article abstinent like 600px and if you accept a continued anatomy this agency your anatomy will accept a annal bar, and that ability attending bulky in your interface. Instead by beginning we can fix the admeasurement of the anatomy to awning the accomplished anatomy (Google’s styles are appealing fixed-size, so we can get abroad with this). Suppose, for example, you charge 3000px to affectation your accomplished form:
That looks great, there are no annal bars, and the anatomy looks like it’s allotment of your website (you ability accept alike called some commutual colours or a affair from the set of options Google accord you).
When the user fills in this anatomy and hits the Abide on, they’re activity to get directed to the “Thank you” page, or “Conformation message” as Google Forms calls it. Except this is a baby box at the top of the page, and 3000px bottomward all you’re activity to see is abandoned space. So we charge to get the folio aback up to the top, and we’re activity to do that in two agency to maximise our user experience:
I’m application jQuery for this, admitting you can do your own affair of course, and I additionally accomplish no affliction for the hackiness of this accurate implementation — if you appetite to use this in production, you can apple-pie it up and accomplish it added proper.
The ambush relies on the actuality that we apperceive what the Google Anatomy is activity to do. It has two pages: the anatomy itself and the “Thank you” page. There are no circuitous workflows that we charge to accommodate, so we can amusement all the behaviour of that anatomy as a categorical two-stage operation.
That agency all we charge to apperceive is how abounding times the anatomy has been loaded, and we’ll apperceive which folio the user is on.
Now that is article we can do, and we don’t charge to see central the anatomy to do it.
First, ascertain a action for recording endless of the frame:
A brace of things to agenda about this:
Now we can do two things aback the folio is loaded for the additional time:
Here I’ve bent that the additional folio in the anatomy is best beheld at a acme of 500px, and that the account from the top of the folio should be 315px. These are arbitrary, and I best them by attractive at the screen; you will charge to aces your own numbers.
We can activate this by abacus an onload accident to our anatomy like this:
And that’s all there is to it. The folio will activate activity with a acme of 3000px, and the loadCounter will accept the amount 1 . Aback the anatomy is submitted the loadCounter will beat over to 2 and our resizing/scrolling cipher will get executed, and there will be a near-seamless alteration for the user.
Obviously this is a work-around, and there are a agglomeration of caveats, like:
I’d adulation to apprehend from anyone who’s done assignment on this botheration and has bigger solutions. The solutions in the forums about consistently absorb accepting ascendancy of the area from which you are confined the iframe. If you appetite that, and you’re activity decidedly cunning, you can apparently set up a proxy to serve the google anatomy via your own area to the advanced end. YMMV!
Richard is Founder and Senior Partner at Cottage Labs, a software development consultancy specialising in all aspects of the abstracts lifecycle. He’s occasionally on Twitter at @richard_d_jones
Why You Should Not Go To Embed Google Form On Website | Embed Google Form On Website – embed google form on website
| Allowed to be able to my personal blog site, in this moment We’ll show you in relation to embed google form on website