我正在尝试将 $GLABALS 变量发布到另一个 php 文件并让它在弹出窗口中打开并使用 $GLOBLAS 变量的值加载 printOnly.php 文件(它传递 $dom 使用的 xml 文件的名称。
目前它打开弹出窗口但找不到发布的变量的值,但它还将变量加载到现有的导航器窗口中,在该窗口中检索发布的变量的值没有问题。我希望主窗口保留在原始 php 页面上,并且只将表单中调用的文件加载到弹出窗口中。
在原始页面上,我有:
<form name ="printView" method ="post" action="printOnly.php" target="popUp" >
<input type="hidden" name="toPopFile" value="'.$GLOBALS["file"].'" />
<input type="image" value="submit" class="button" title="print view" src="graphics/printview.png" align="middle" onclick="javascript:viewClick(\'printOnly.php\')" />
</form>
在要加载到弹出窗口中的文件中,我有:
$file=basename($_POST['toPopFile']); // value to be retrieved which is the name of the xml file currently loaded in original php file
$dom = new domDocument;
if (file_exists($file)) {
$dom->load($file);
} else {
exit('Error ! xml file not found.');
}
这是从外部 .js 文件调用的 javascript 函数
var view;
function viewClick(url) {
view= window.open(url,'view text','menubar=yes,scrollbars=yes,resizable=yes,width=640,height=700');
view.focus();
}
帮助!(保持简单,我可以鹦鹉学舌,但我并不总是明白我在做什么)