简体   繁体   中英

Javascript popup in Drupal without redirect?

I am attempting to create a javascript function to create a popup window from my drupal site.

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. 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.

Any advice?

Have you tried to use an absolute link in your function? I think the issue comes from a misunderstanding between your function and Drupal URL Rewriting feature. If it is the case you can simply fix it by using the full absolute url to your html file.

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()

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

Cheers

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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