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 wo开发者_如何学Gorks 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:
This should work. If you require your module to work with different domains, you can use the Drupal PHP function : base_path()function popitup() {
newwindow = window.open('http://www.yoursite.com/yourpath/popup.html', 'name', 'height=200, width=150');
if (window.focus) {newwindow.focus()}
return false;
}
print base_path(); // This will retrieve drupal installation base path.
Cheers
精彩评论