Accessing a text Input inside iFrame (Google Forms) - Javascript -


cutting chase:

i have google forms survey, , need dynamically edit 1 of text-inputs.

the forms survey 1 out of 6 possible surveys, javascript adds it: '<iframe name="survey" id="ifrm" src="https://spreadsheets.google.com/spreadsheet/embeddedform?formkey=dhpym1nvtfn4oelnwnbjwutjdhhld2c6mq" width="760" height="623" frameborder="0" marginheight="0" marginwidth="0">loading...</iframe>'

the trouble accessing textbox - used settimeout() wait until iframe loaded properly. , want this:

function writeencoded() {         alert("now attempting inject");           var if = document.getelementbyid('ifrm');         alert( if);           //works here         var form = if.contentwindow.document; //does not run.         alert (form);         form.getelementbyid('entry_3').value = "hi";      } 

any ideas what's going wrong? guys.

you’re seeing same origin policy in action.

on web, content on 1 website mostly not allowed interact content on another.

since iframe loaded https://spreadsheets.google.com , (i’m guessing) webpage on website (like http://example.com/), javascript can’t see inside iframe (and google’s javascript can’t see on webpage).

why? same origin policy meant protect you. without it, load google.com iframe on website and, javascript, read email address (if you’re logged in). or, load facebook.com , read name , quite bit of other personal information out of page.


Comments

Popular posts from this blog

linux - Using a Cron Job to check if my mod_wsgi / apache server is running and restart -

actionscript 3 - TweenLite does not work with object -

jQuery Ajax Render Fragments OR Whole Page -