问题描述
|
我正在尝试创建一个JavaScript函数,以从我的drupal网站创建一个弹出窗口。
function popitup() {
newwindow=window.open(\'popup.html\',\'name\',\'height=200,width=150\');
if (window.focus) {newwindow.focus()}
return false;
}
除Drupal将该URL重定向到我的模块的主页之外,此方法工作正常。我希望能够使用原始HTML文件,或者至少使用Drupal Hook页面而不使用任何Drupal主题。
有什么建议吗?
解决方法
您是否尝试过在函数中使用绝对链接?我认为问题出在您的功能与Drupal URL重写功能之间的误解。如果是这种情况,您可以使用html文件的完整绝对URL进行修复。
例如:
function popitup() {
newwindow = window.open(\'http://www.yoursite.com/yourpath/popup.html\',\'name\',\'height=200,width=150\');
if (window.focus) {newwindow.focus()}
return false;
}
这应该工作。如果您需要模块使用不同的域,则可以使用Drupal PHP函数:base_path()
print base_path(); // This will retrieve drupal installation base path.
干杯