简体   繁体   English

Drupal 中的 Javascript 弹出窗口没有重定向?

[英]Javascript popup in Drupal without redirect?

I am attempting to create a javascript function to create a popup window from my drupal site.我正在尝试创建一个 javascript function 从我的 Z08D15A4AEF553492D8Z71CDD514 站点创建一个弹出窗口 window

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

This works fine, except that Drupal redirects the url to the main-page of my module.这工作正常,除了 Drupal 将 url 重定向到我的模块的主页。 I'd like to be able to use a raw HTML file, or at the very least a Drupal Hook page without any Drupal theming.我希望能够使用一个原始的 HTML 文件,或者至少是一个没有任何 Drupal 主题的 Drupal Hook 页面。

Any advice?有什么建议吗?

Have you tried to use an absolute link in your function?您是否尝试在 function 中使用绝对链接? I think the issue comes from a misunderstanding between your function and Drupal URL Rewriting feature.我认为问题来自您的 function 和 Drupal URL 重写功能之间的误解。 If it is the case you can simply fix it by using the full absolute url to your html file.如果是这种情况,您可以通过使用完整的绝对 url 到您的 html 文件来简单地修复它。

Ex:前任:

function popitup() {
newwindow = window.open('http://www.yoursite.com/yourpath/popup.html', 'name', 'height=200, width=150'); if (window.focus) {newwindow.focus()} return false; }
This should work. 这应该有效。 If you require your module to work with different domains, you can use the Drupal PHP function: base_path() 如果您需要您的模块使用不同的域,您可以使用 Drupal PHP function:base_path()

 print base_path(); // This will retrieve drupal installation base path.

Cheers干杯

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM