2011-06-04 104 views
0

我试图创建一个JavaScript函数来从我的drupal站点创建一个弹出窗口。Drupal中的Javascript弹出窗口不重定向?

function popitup() { 
    newwindow=window.open('popup.html','name','height=200,width=150'); 
    if (window.focus) {newwindow.focus()} 
    return false; 
} 

这工作正常,除了Drupal重定向到我的模块的主页的URL。我希望能够使用原始HTML文件,或者至少在没有任何Drupal主题的情况下使用Drupal Hook页面。

有什么建议吗?

回答

3

您是否尝试过在函数中使用绝对链接?我认为这个问题来自您的函数和Drupal URL重写功能之间的误解。如果是这种情况,你可以通过使用完整的绝对url到你的html文件来修复它。

例如:

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. 

干杯