Javascript and buidling data, then returning to iframe -


i trying function build data give , display in iframe. cant display anything. based off code, ideas?

function playblackjack() {    var data = "<table border=0 style='margin:auto'>"    data += "<tr>"    data += "<td><form><input type="button" onclick="javascript:dealcards()" value="deal > > >"></form></td>"    data += showcards(0)    data += "<td><form><input type="button" onclick="javascript:hitcard()" value="< < < hit me"></form></td>"    data += "</tr></table> "    return productarea.document.writeln(data)    productarea.document.close() } 

  1. are sure don't have cross-domain problems. cannot manipulate contents of cross-domain iframe.
  2. if on different domains can use message passing. example, if document contains iframe element contains document b, , script in document calls postmessage() on window object of document b, message event fired on object, marked originating window of document a. script in document might like

    var o = document.getelementsbytagname('iframe')[0]; o.contentwindow.postmessage('hello world', 'http://b.example.org/'); 

to register event handler incoming events, script use addeventlistener() (or similar mechanisms). example, script in document b might like:

window.addeventlistener('message', receiver, false); function receiver(e) {   if (e.origin == 'http://example.com') {     if (e.data == 'hello world') {       e.source.postmessage('hello', e.origin);     } else {       alert(e.data);     }   } } 

this script first checks domain expected domain, , looks @ message, either displays user, or responds sending message document sent message in first place.

via invoking javascript code in iframe parent page

via http://dev.w3.org/html5/postmsg/#web-messaging


Comments