Remove frames and loading content into the div

主宰稳场 提交于 2020-01-16 18:48:06

问题


Is there anyway i can unload a page that has been loaded inside an iframe? it likely removing the windows and loading content from other pages into the div?

I am using iframe on my main screen to call a file left_nav.php

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

In left_nav functions and methods to load content from other pages like main_title.php

Function created in left_nav.php file below

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;
}

This is a js script in left_nav to load loadFrame2

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;
}

Funtions created in main_title.php file.

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:


In the last line of code where the new iframe source is set, you're using the href attribute instead of the src. Since iframe does not have an href attribute, that would explain the lack of results.

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

Try changing to that and see if it works.



来源:https://stackoverflow.com/questions/26151012/remove-frames-and-loading-content-into-the-div

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!