删除帧并将内容加载到div中

时间:2014-10-01 21:31:28

标签: javascript php html frames

无论如何我可以卸载已经加载到iframe中的页面吗?它可能会删除 窗口并将其他页面中的内容加载到div

我在主屏幕上使用iframe来调用文件left_nav.php

<iframe src='left_nav.php' name='left_nav' class="daemon" scrolling="auto" frameborder='0' height='100%' width="100%"></iframe>

left_nav函数和方法中加载来自其他网页的内容,例如main_title.php

left_nav.php文件下面创建的功能

setEncounter(edate, eid, frname) {
  if (eid == active_encounter) return;
  if (!eid) edate = '<?php xl('None','e'); ?>';
  var str = '<b>' + edate + '</b>';
  setDivContent('current_encounter', str);
  active_encounter = eid;
  encounter_locked=isEncounterLocked(active_encounter);
  reloadEncounter(frname);
  syncRadios();
  var encounter_block = $(parent.Title.document.getElementById('current_encounter_block'));
  var encounter = $(parent.Title.document.getElementById('current_encounter'));
  var estr = '<a href=\'javascript:;\' onclick="parent.left_nav.loadCurrentEncounterFromTitle()">       <b>' + edate + ' (' + eid + ')</b></a>';
  encounter.html( estr );
  encounter_block.show();
}


function loadCurrentEncounterFromTitle() {
  top.restoreSession();
  top.frames[ parent.left_nav.getEncounterTargetFrame('enc')     ].location='../patient_file/encounter/encounter_top.php';
}


function getEncounterTargetFrame( name ) {
  var bias = <?php echo $primary_docs[ 'enc'  ][ 1 ]?>;
  var f = document.forms[0];
  var r = 'RTop';
  if (f.cb_top.checked) {
    if ( bias == 2 ) {
        r = 'RTop';

    }
  }
  return r;
}

这是加载loadFrame2

left_nav中的js脚本
function loadFrame2(fname, frame, url) {
  var usage = fname.substring(3);
  if (active_pid == 0 && usage > '0') {
    alert('<?php xl('You must first select or add a visitor.','e') ?>');
    return false;
  }
  if (active_encounter == 0 && usage > '1') {
    alert('<?php xl('You must first select or create an encounter.','e') ?>');
    return false;
  }
  if (encounter_locked && usage > '1') {
    alert('<?php echo xls('This encounter is locked. No new forms can be added.') ?>');
    return false;
  }
  var f = document.forms[0];
  top.restoreSession();
  var i = url.indexOf('{PID}');
  if (i >= 0) url = url.substring(0,i) + active_pid + url.substring(i+5);
  if(f.sel_frame) {
    var fi = f.sel_frame.selectedIndex;
    if (fi == 1) frame = 'RTop'; else if (fi == 2) frame = 'RBot';
  }
  if (!f.cb_bot.checked) frame = 'RTop';
  top.frames[frame].location = '<?php echo "$web_root/interface/" ?>' + url;
  if (frame == 'RTop') topName = fname;
  return false;
}

main_title.php文件中创建的功能。

function toencounter(rawdata) {
  document.getElementById('EncounterHistory').selectedIndex=0;
  if(rawdata=='') {
    return false;
  } else if (rawdata=='New Encounter') {
    top.window.parent.left_nav.loadFrame2('nen1','RBot','forms/newpatient/new.php?   autoloaded=1&calenc=')
    return true;
  } else if (rawdata=='Past Encounter List') {
    top.window.parent.left_nav.loadFrame2('pel1','RBot','patient_file/history/encounters.php')
    return true;
  }
  var parts = rawdata.split("~");
  var enc = parts[0];
  var datestr = parts[1];
  var f = top.window.parent.left_nav.document.forms[0];
  frame = 'RBot';
  if (!f.cb_bot.checked) {
    frame = 'RTop';
  }

  parent.left_nav.setEncounter(datestr, enc, frame);
  top.frames[frame].location.href  = '../patient_file/encounter/encounter_top.php?set_encounter=' +     enc;
}

1 个答案:

答案 0 :(得分:0)

在设置新iframe源的最后一行代码中,您使用的是href属性而不是src。由于iframe没有href属性,这可以解释缺少结果。

top.frames[frame].src  = '../patient_file/encounter/encounter_top.php?set_encounter=' +     enc;

尝试更改为该功能,看看是否有效。