2つのJavaScriptファイルがあります。この最初のファイルは変数を設定し、次の名前の別のファイルの内容を書き込みますiframe.js
。
/* Parent File */
var aff_id = 2; // Your affiliate ID
var aff_source_id='1'; // Your site ID
var aff_source_subid=''; // Your custom tracking ID
var thankyouUrl = ''; // Leave blank if you don't have a thank you page
var live = 0; // 1 for production
var lead_type = 1; // Auto insurance
document.write(unescape('%3Cscript src="'+site+'/api/js/iframe.js"%3E%3C/script%3E'));
/* Child File */
if(!site) var site='https://leadthis.com';
$(function(){
var height,width,src = 'http://lead/api/iframe/insurance/auto.php#'+encodeURIComponent(document.location.href )+'?aff_id='+aff_id+'&aff_source_id='+encodeURIComponent(aff_source_id)+'&aff_source_subid='+encodeURIComponent(aff_source_subid)+'&live='+live,
emarfi=$('<iframe id="appframe" src="'+src+'" scrolling="no" frameborder="0"><\/iframe>').appendTo('#emarfi');
});
document.write('<div id="emarfi"><\/div>');
親ファイルに書き込まれるiframedコンテンツを処理するために、この子ファイルに実行可能なJavaScriptコードを記述したいと思います。これは可能ですか?私はこれを試しました:
document.write("$(function(){ $('iframe').load(function(){alert('Hello Iframe');})});");
私は何が間違っているのですか?