parameter passing - How to pass a value from parent to a fancybox 2.1.7 element, afterShow? -
$.fancybox({ type: 'iframe', href: url, aftershow: function() { var name = parent.$('#pname').val(); $('#fname').val(name); $('#fname').focus(); return true; }, beforeclose: function(){ clscarr(); }, where pname input box in parent document , fname input box in fancybox document. how put value of pname in fname? aftershow knows value of pname, not putting in fname.
i saw iframe in fancybox. it's interesting trying iframes "talk" parent document, i'm not positive i've got 100% right. :)
var name = parent.getelementbyid("lst-ib").value; document.queryselector("#fancybox-content iframe").contentdocument.getelementbyid("fname").value = name; my thought behind $.fancybox running in parent document, , when use parent.$('#pname').val() equivalent running $('#pname').val(), since parent not able 'higher' root document.
thus, if theory correct, need iframe , access contentdocument (or perhaps document), , fetch id of element inside iframe.
this would, obviously, work if iframe using same domain parent document. believe browsers implement sort of cross-domain verification nowadays.
Comments
Post a Comment